Пример #1
0
        public void FixOrcsWithoutProps_OrphanedFootnoteAndValidPicture()
        {
            CheckDisposed();

            IScrBook  exodus = CreateExodusData();
            StTxtPara para   = AddPara(exodus.SectionsOS[2]);

            AddVerse(para, 2, 3, "ORC is here, you see, my friend.");

            // Update the paragraph contents to include the picture
            ITsStrBldr    tsStrBldr = para.Contents.UnderlyingTsString.GetBldr();
            ITsStrFactory factory   = TsStrFactoryClass.Create();
            CmPicture     pict      = new CmPicture(Cache, "c:\\junk.jpg",
                                                    factory.MakeString("Test picture", Cache.DefaultVernWs),
                                                    StringUtils.LocalPictures);

            Assert.IsNotNull(pict);
            pict.InsertOwningORCIntoPara(tsStrBldr, 11, 0);
            para.Contents.UnderlyingTsString = tsStrBldr.GetString();

            // Update the paragraph contents to include the (orphaned) footnote marker
            CreateFootnote(exodus, 1, 0, 1, 19, ScrStyleNames.CrossRefFootnoteParagraph, true);

            TeScrInitializer scrInit = new TestTeScrInitializer(Cache);
            List <string>    report  = (List <string>)ReflectionHelper.GetResult(scrInit, "FixOrcsWithoutProps");

            VerifyNoOrphanedFootnotes();
            VerifyResourceForFixedOrphans();

            Assert.AreEqual(1, report.Count);
            Assert.AreEqual("EXO 1:2 - Deleted corrupted footnote marker or picture anchor", report[0]);

            Assert.AreEqual(0, exodus.FootnotesOS.Count);
        }
Пример #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert a picture at the current selection of the active rootsite.
        /// </summary>
        /// <param name="initialPicture">The existing CmPicture being modified, if any</param>
        /// <param name="srcFilename">The path to the original filename (an internal copy will
        /// be made in this method)</param>
        /// <param name="captionTss">The caption</param>
        /// <param name="sFolder">The name of the CmFolder where picture should be stored</param>
        /// ------------------------------------------------------------------------------------
        public void UpdatePicture(CmPicture initialPicture, string srcFilename,
                                  ITsString captionTss, string sFolder)
        {
            CheckDisposed();

            initialPicture.UpdatePicture(srcFilename, captionTss, sFolder);
        }
Пример #3
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="PicturePropertiesDialog"/> class.
        /// </summary>
        /// <param name="cache">The FdoCache to use</param>
        /// <param name="initialPicture">The CmPicture object to set all of the dialog
        /// properties to, or null to edit a new picture</param>
        /// <param name="helpTopicProvider">typically FwApp.App</param>
        /// <param name="fAnalysis">true to use analysis writign system for caption</param>
        /// -----------------------------------------------------------------------------------
        public PicturePropertiesDialog(FdoCache cache, CmPicture initialPicture,
                                       IHelpTopicProvider helpTopicProvider, bool fAnalysis)
        {
            if (cache == null)
            {
                throw(new ArgumentNullException("cache", "The FdoCache cannot be null"));
            }

            Logger.WriteEvent("Opening 'Picture Properties' dialog");

            m_cache             = cache;
            m_initialPicture    = initialPicture;
            m_helpTopicProvider = helpTopicProvider;
            m_captionWs         = fAnalysis ? m_cache.DefaultAnalWs : m_cache.DefaultVernWs;

            InitializeComponent();

            if (m_helpTopicProvider != null)             // Could be null during tests
            {
                helpProvider = new HelpProvider();
                helpProvider.HelpNamespace = DirectoryFinder.FWCodeDirectory +
                                             m_helpTopicProvider.GetHelpString("UserHelpFile", 0);
                helpProvider.SetHelpKeyword(this, m_helpTopicProvider.GetHelpString(s_helpTopic, 0));
                helpProvider.SetHelpNavigator(this, HelpNavigator.Topic);
            }
        }
Пример #4
0
        public void CmPictureConstructor_FullParamsMultipleDescriptionVariants()
        {
            CheckDisposed();
            Dictionary <int, string> descriptions = new Dictionary <int, string>();

            descriptions[Cache.DefaultAnalWs] = "My picture.";
            descriptions[Cache.DefaultVernWs] = "Mi foto.";
            ICmPicture pictNew = new CmPicture(Cache, StringUtils.LocalPictures, 0, null, descriptions,
                                               m_pict.PictureFileRA.AbsoluteInternalPath, "left", "1-2",
                                               "Don't use this picture in your book!",
                                               m_pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString,
                                               PictureLocationRangeType.ParagraphRange, "62");

            Assert.IsTrue(pictNew != m_pict);
            string internalPathNew = pictNew.PictureFileRA.InternalPath;

            Assert.AreEqual(pictNew.PictureFileRA.AbsoluteInternalPath, internalPathNew, "Files outside LangProject.ExtLinkRootDir are stored as absolute paths");
            m_internalFilesToDelete.Add(pictNew.PictureFileRA.AbsoluteInternalPath);
            Assert.AreEqual(m_internalPath, internalPathNew);
            AssertEx.AreTsStringsEqual(m_pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString,
                                       pictNew.Caption.VernacularDefaultWritingSystem.UnderlyingTsString);
            Assert.AreEqual(m_pict.PictureFileRA.OwnerHVO, pictNew.PictureFileRA.OwnerHVO);
            Assert.AreEqual("My picture.", pictNew.Description.AnalysisDefaultWritingSystem.Text);
            Assert.AreEqual("Mi foto.", pictNew.Description.VernacularDefaultWritingSystem.Text);
            Assert.AreEqual(PictureLayoutPosition.LeftAlignInColumn, pictNew.LayoutPos);
            Assert.AreEqual(62, pictNew.ScaleFactor);
            Assert.AreEqual(PictureLocationRangeType.ParagraphRange, pictNew.LocationRangeType);
            Assert.AreEqual(1, pictNew.LocationMin);
            Assert.AreEqual(2, pictNew.LocationMax);
            Assert.AreEqual("Don't use this picture in your book!",
                            pictNew.PictureFileRA.Copyright.VernacularDefaultWritingSystem.Text);
        }
Пример #5
0
        public void CmPictureConstructor_FromTextRep()
        {
            CheckDisposed();

            ICmPicture pictNew = new CmPicture(Cache, ((CmPicture)m_pict).TextRepOfPicture,
                                               StringUtils.LocalPictures);

            Assert.IsTrue(pictNew != m_pict);
            string internalPathNew = pictNew.PictureFileRA.InternalPath;

            Assert.IsNotNull(internalPathNew, "Internal path not set correctly");
            Assert.IsTrue(pictNew.PictureFileRA.AbsoluteInternalPath == internalPathNew, "Files outside LangProject.ExtLinkRootDir are stored as absolute paths");
            m_internalFilesToDelete.Add(pictNew.PictureFileRA.AbsoluteInternalPath);
            Assert.AreEqual(m_internalPath, internalPathNew);
            Assert.IsTrue(internalPathNew.EndsWith(".jpg"));
            AssertEx.AreTsStringsEqual(m_pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString,
                                       pictNew.Caption.VernacularDefaultWritingSystem.UnderlyingTsString);
            Assert.AreEqual(m_pict.PictureFileRA.OwnerHVO, pictNew.PictureFileRA.OwnerHVO);
            Assert.IsNull(pictNew.Description.AnalysisDefaultWritingSystem.Text);
            // REVIEW (TE-7745): What should the default PictureLayoutPosition value be?
            Assert.AreEqual(PictureLayoutPosition.CenterInColumn, pictNew.LayoutPos);
            Assert.AreEqual(100, pictNew.ScaleFactor);
            Assert.AreEqual(PictureLocationRangeType.AfterAnchor, pictNew.LocationRangeType);
            Assert.AreEqual(0, pictNew.LocationMin);
            Assert.AreEqual(0, pictNew.LocationMax);
            Assert.IsNull(pictNew.PictureFileRA.Copyright.VernacularDefaultWritingSystem.Text);
        }
Пример #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert a picture at the current selection of the active rootsite.
        /// </summary>
        /// <param name="srcFilename">The path to the original filename (an internal copy will
        /// be made in this method)</param>
        /// <param name="captionTss">The caption</param>
        /// <param name="sFolder">The name of the CmFolder where picture should be stored</param>
        /// ------------------------------------------------------------------------------------
        public CmPicture InsertPicture(string srcFilename, ITsString captionTss, string sFolder)
        {
            CheckDisposed();

            CmPicture pict = new CmPicture(m_cache, srcFilename, captionTss, sFolder);

            // Add the ORC to the text at the insertion point.
            InsertPicture(pict);
            return(pict);
        }
Пример #7
0
        public void ExportPicture_MultipleWS()
        {
            // Create a picture that has a caption with three different writing systems.
            ITsStrBldr   tssBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, InMemoryFdoCache.s_wsHvos.De);
            tssBldr.ReplaceRgch(0, 0, "photo", 5, propsBldr.GetTextProps());
            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, InMemoryFdoCache.s_wsHvos.Ur);
            tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " tasvir", 7, propsBldr.GetTextProps());
            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, Cache.DefaultVernWs);
            tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " picture caption", 16, propsBldr.GetTextProps());
            CmPicture picture = new CmPicture(m_inMemoryCache.Cache, @"c:\filename.jpg", tssBldr.GetString(), "folder");

            // Set up for export
            StringWriter  stream = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(stream);

            writer.Formatting = Formatting.None;
            m_exporter        = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
                                              "ExportPicture_MultipleWS");
            ReflectionHelper.SetField(m_exporter, "m_writer", writer);

            // Export the picture to XML
            ReflectionHelper.CallMethod(m_exporter, "ExportPicture", picture);

            // Check the results of the exported picture.
            //   Set up expected results.
            string defaultDir = DirectoryFinder.FWDataDirectory;
            // TODO (TE-7756): Support OXES export and import of new properties that have been
            // added to the CmPicture model
            string strExpected = "<figure src=\"filename.jpg\"><!--path=\"" + defaultDir + "\\filename\"-->" +
                                 "<caption><trGroup><tr><foreign xml:lang=\"de\">photo</foreign>" +
                                 "<foreign xml:lang=\"ur\"> tasvir</foreign> picture caption</tr></trGroup></caption></figure>";
            XmlDocument expected = new XmlDocument();

            expected.Load(new StringReader(strExpected));

            //   Get actual results.
            XmlDocument actual = new XmlDocument();

            actual.Load(new StringReader(stream.ToString()));

            string strDifference;

            if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
            {
                Assert.Fail(strDifference);
            }
        }
Пример #8
0
        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);
                }
            }
        }
Пример #9
0
        bool m_fThumbnail;         // true to force smaller size.
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public PictureSlice(CmPicture picture)
        {
            m_picBox          = new PictureBox();
            m_picBox.Click   += new EventHandler(pb_Click);
            m_picBox.Location = new Point(0, 0);            // not docked, because width may not be whole width
            m_picBox.SizeMode = PictureBoxSizeMode.Zoom;
            m_picture         = picture;
            InstallPicture(m_picBox);
            // We need an extra layer of panel because the slice's control is always docked,
            // and we don't want that for the picture box.
            Panel panel = new Panel();

            panel.Controls.Add(m_picBox);
            panel.SizeChanged += new EventHandler(panel_SizeChanged);
            this.Control       = panel;
        }
Пример #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Inserts a ORC pointing to hvoObjToInsert at the current selection location.
        /// Enhance JohnT: should move this to RootSite or similar location where all clients
        /// can readily use it.
        /// </summary>
        /// <param name="pict">The picture to insert</param>
        /// ------------------------------------------------------------------------------------
        private void InsertPicture(CmPicture pict)
        {
            // get selection information
            ITsString tss;
            int       ich;
            bool      fAssocPrev;
            int       hvoObj;
            int       ws;
            int       propTag;

            CurrentSelection.Selection.TextSelInfo(true, out tss, out ich, out fAssocPrev,
                                                   out hvoObj, out propTag, out ws);
            SelectionHelper oldSelection = CurrentSelection;

            // If inserting a picture over a user prompt, need to set up info for a proper insertion
            // in the empty paragraph.
            if (propTag == SimpleRootSite.kTagUserPrompt)
            {
                ich = 0;
                ITsStrFactory factory = TsStrFactoryClass.Create();
                tss     = factory.MakeString(string.Empty, m_cache.DefaultVernWs);
                propTag = (int)StTxtPara.StTxtParaTags.kflidContents;
            }

            InsertPictureOrc(pict, tss, ich, hvoObj, propTag, ws);
            SelectionHelper helper = CurrentSelection;

            if (helper == null)
            {
                oldSelection.SetTextPropId(SelectionHelper.SelLimitType.Anchor, (int)StTxtPara.StTxtParaTags.kflidContents);
                oldSelection.SetTextPropId(SelectionHelper.SelLimitType.End, (int)StTxtPara.StTxtParaTags.kflidContents);
                oldSelection.IchAnchor = 0;
                oldSelection.IchEnd    = 0;
                oldSelection.SetSelection(true);
                Debug.Assert(CurrentSelection != null);
            }
            else
            {
                helper.IchAnchor = helper.IchEnd = ich + 1;
                helper.SetSelection(true);
            }
        }
Пример #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a picture (no caption set).
        /// </summary>
        /// <param name="para">Paragraph to insert picture into</param>
        /// <param name="ichPos">The 0-based character offset into the paragraph</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        protected ICmPicture InsertTestPicture(StTxtPara para, int ichPos)
        {
            // Create the picture
            ICmFolder folder = m_fdoCache.LangProject.PicturesOC.Add(new CmFolder());
            ICmFile   file   = folder.FilesOC.Add(new CmFile());

            file.InternalPath = "there";
            int        newHvo  = m_fdoCache.CreateObject(CmPicture.kClassId);
            ICmPicture picture = new CmPicture(m_fdoCache, newHvo);

            picture.PictureFileRA = file;

            // Update the paragraph contents to include the footnote marker
            ITsStrBldr tsStrBldr = para.Contents.UnderlyingTsString.GetBldr();

            (picture as CmPicture).InsertOwningORCIntoPara(tsStrBldr, ichPos, 0);             // Don't care about ws
            para.Contents.UnderlyingTsString = tsStrBldr.GetString();

            return(picture);
        }
Пример #12
0
        public void showProperties()
        {
            CheckDisposed();
            CmPicture pic = (CmPicture)this.Object;

            using (PicturePropertiesDialog dlg = new PicturePropertiesDialog(m_cache, pic,
                                                                             FwApp.App, true))
            {
                if (dlg.Initialize())
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        string strLocalPictures = SIL.FieldWorks.Common.RootSites.EditingHelper.DefaultPictureFolder;
                        pic.UpdatePicture(dlg.CurrentFile, dlg.Caption, strLocalPictures, pic.Cache.DefaultAnalWs);
                        InstallPicture(m_picBox);
                        m_lastSize = new Size(0, 0);                         // forces OnSizeChanged to do something (we need to adjust to new aspect ratio).
                        OnSizeChanged(new EventArgs());
                    }
                }
            }
        }
Пример #13
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");
            }
        }
Пример #14
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Advances the enumerator to the next element of the collection.
        /// </summary>
        /// <returns>
        /// true if the enumerator was successfully advanced to the next element; false if the
        /// enumerator has passed the end of the collection.
        /// </returns>
        /// <exception cref="T:System.InvalidOperationException">The collection was modified
        /// after the enumerator was created. </exception>
        /// ------------------------------------------------------------------------------------
        public bool MoveNext()
        {
            if (m_currentScrText == null)
            {
                return(false);
            }

            while (++m_currentScrText.m_iRun < m_currentScrText.m_paraTss.RunCount)
            {
                m_internalToken.m_fParagraphStart = (m_currentScrText.m_iRun == 0);

                ITsTextProps runProps      = m_currentScrText.m_paraTss.get_Properties(m_currentScrText.m_iRun);
                string       charStyleName = runProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
                m_internalToken.m_sText      = m_currentScrText.m_paraTss.get_RunText(m_currentScrText.m_iRun);
                m_internalToken.m_paraOffset = m_currentScrText.m_paraTss.get_MinOfRun(m_currentScrText.m_iRun);
                int var;
                int ws = runProps.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
                m_internalToken.m_icuLocale = GetLocale(ws);
                m_internalToken.Ws          = ws;
                switch (runProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle))
                {
                case ScrStyleNames.VerseNumber:
                    if (!m_foundStart || string.IsNullOrEmpty(m_internalToken.m_sText))
                    {
                        continue;
                    }

                    m_internalToken.m_textType = TextType.VerseNumber;
                    int verse = ScrReference.VerseToIntStart(m_internalToken.m_sText);
                    if (verse != 0)
                    {
                        m_internalToken.m_startRef.Verse = verse;
                    }
                    verse = ScrReference.VerseToIntEnd(m_internalToken.m_sText);
                    if (verse != 0)
                    {
                        m_internalToken.m_endRef.Verse = verse;
                    }

                    break;

                case ScrStyleNames.ChapterNumber:
                    if (string.IsNullOrEmpty(m_internalToken.m_sText))
                    {
                        continue;
                    }
                    int chapter = 0;
                    try
                    {
                        chapter = ScrReference.ChapterToInt(m_internalToken.m_sText);
                    }
                    catch
                    {
                        // Ignore exceptions. We'll flag them later as errors.
                    }
                    if (!m_foundStart)
                    {
                        if (m_chapterNum != chapter)
                        {
                            continue;
                        }
                        m_foundStart = true;
                    }
                    else if (m_chapterNum > 0 && m_chapterNum != chapter)
                    {
                        // Stop if we're only getting tokens for a single chapter (unless
                        // this is an (erroneous) second occurrence of the same chapter)
                        return(false);
                    }
                    m_internalToken.m_textType         = TextType.ChapterNumber;
                    m_internalToken.m_startRef.Chapter = m_internalToken.m_endRef.Chapter = chapter;
                    m_internalToken.m_startRef.Verse   = m_internalToken.m_endRef.Verse = 1;
                    break;

                default:
                {
                    if (!m_foundStart)
                    {
                        continue;
                    }
                    // Deal with footnotes and picture captions
                    Guid guidObj = StringUtils.GetGuidFromRun(m_currentScrText.m_paraTss, m_currentScrText.m_iRun, runProps);
                    if (guidObj == Guid.Empty)
                    {
                        m_internalToken.m_textType = m_currentScrText.DefaultTextType;
                    }
                    else if (m_outerText != null)
                    {
                        // It was possible through copy/paste to put ORCs into footnotes or pictures, but that is no
                        // longer allowed. This tokenizing code won't handle the nesting correctly, so just ignore
                        // the nested ORC. See TE-8609.
                        continue;
                    }
                    else
                    {
                        m_fOrcWasStartOfPara = m_internalToken.m_fParagraphStart;
                        int hvo = m_book.Cache.GetIdFromGuid(guidObj);
                        if (hvo > 0)
                        {
                            switch (m_book.Cache.GetClassOfObject(hvo))
                            {
                            case StFootnote.kclsidStFootnote:
                                m_outerText = m_currentScrText;
                                // footnotes are StTexts
                                m_currentScrText = new TokenizableText(new StText(m_book.Cache, hvo), TextType.Note);
                                return(MoveNext());

                            case CmPicture.kclsidCmPicture:
                            {
                                m_outerText = m_currentScrText;
                                CmPicture pict = new CmPicture(m_book.Cache, hvo);
                                m_currentScrText = new TokenizableText(
                                    pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString,
                                    ScrStyleNames.Figure, TextType.PictureCaption, pict,
                                    (int)CmPicture.CmPictureTags.kflidCaption);
                                return(MoveNext());
                            }
                            }
                        }
                    }
                }
                break;
                }
                m_internalToken.m_fNoteStart = (m_internalToken.m_textType == TextType.Note &&
                                                m_internalToken.m_fParagraphStart && m_currentScrText.m_iPara == 0);
                m_internalToken.m_paraStyleName = m_currentScrText.ParaStyleName;
                m_internalToken.m_charStyleName = charStyleName != null ? charStyleName : string.Empty;
                m_internalToken.m_object        = m_currentScrText.m_obj;
                m_internalToken.m_flid          = m_currentScrText.m_flid;

                // We need the current token to be a copy of our internal token so we don't change the
                // internal variables of whatever was returned from the enumerator.
                m_currentToken = m_internalToken.Copy();
                return(true);
            }
            // Finished that paragraph and didn't find any more runs; try next para in this text,
            // if any.
            if (!m_currentScrText.NextParagraph())
            {
                if (!m_foundStart)
                {
                    Debug.Fail("We should have found the desired chapter wtihin the section we were searching.");
                    return(false);
                }
                // Finished that text and didn't find any more paragraphs.
                // If we have been processing an inner text (footnote or picture caption), pop back
                // out to the "outer" one.
                if (m_outerText != null)
                {
                    m_currentScrText = m_outerText;
                    m_outerText      = null;
                    bool result = MoveNext();
                    if (result)
                    {
                        m_currentToken.m_fParagraphStart |= m_fOrcWasStartOfPara;
                        m_fOrcWasStartOfPara              = false;
                    }
                    return(result);
                }

                // Otherwise, try next text, if any.
                if (m_currentScrText.m_text.OwningFlid == (int)ScrBook.ScrBookTags.kflidTitle)
                {
                    // Get first section head text.
                    CurrentSectionIndex = 0;
                }
                else if (m_currentScrText.m_text.OwningFlid == (int)ScrSection.ScrSectionTags.kflidHeading)
                {
                    m_currentScrText = new TokenizableText(m_currentSection.ContentOA,
                                                           m_currentSection.IsIntro ? TextType.Other : TextType.Verse);
                }
                else
                {
                    Debug.Assert(m_currentScrText.m_text.OwningFlid == (int)ScrSection.ScrSectionTags.kflidContent);
                    if (m_iCurrentSection + 1 >= m_book.SectionsOS.Count)
                    {
                        return(false);
                    }
                    CurrentSectionIndex++;
                    if (m_chapterNum > 0 && ScrReference.GetChapterFromBcv(m_currentSection.VerseRefStart) != m_chapterNum)
                    {
                        return(false);
                    }
                }
            }
            return(MoveNext());
        }
Пример #15
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="PicturePropertiesDialog"/> class.
 /// </summary>
 /// <param name="cache">The FdoCache to use</param>
 /// <param name="initialPicture">The CmPicture object to set all of the dialog
 /// properties to, or null to edit a new picture</param>
 /// <param name="helpTopicProvider">typically FwApp.App</param>
 /// -----------------------------------------------------------------------------------
 public PicturePropertiesDialog(FdoCache cache, CmPicture initialPicture,
                                IHelpTopicProvider helpTopicProvider)
     : this(cache, initialPicture, helpTopicProvider, false)
 {
 }
Пример #16
0
 public void CmPictureConstructor_FromTextRep_MissingFilename()
 {
     CheckDisposed();
     ICmPicture pictNew = new CmPicture(Cache, "CmPicture||||||This is a caption||",
                                        StringUtils.LocalPictures);
 }
Пример #17
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);
 }