Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets up a TsString to be returned from the selection helper so that it will appear
        /// to the editing helper as though we're editing a string consisting of only a hyperlink.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SimulateHyperlinkOnly(SelectionHelper selHelper,
                                           IchPosition start, IchPosition end)
        {
            ITsStrBldr bldr = (ITsStrBldr)TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Google", m_ttpHyperlink);
            selHelper.Stub(selH => selH.GetTss(Arg <SelectionHelper.SelLimitType> .Is.Anything))
            .Return(bldr.GetString());

            selHelper.Stub(selH => selH.GetSelProps(Arg <SelectionHelper.SelLimitType> .Is.Anything))
            .Return(m_ttpHyperlink);

            int ichStart = 0;
            int ichEnd   = 0;

            switch (start)
            {
            case IchPosition.EarlyInHyperlink: ichStart = 2; break;

            case IchPosition.EndOfString:
            case IchPosition.EndOfHyperlink: ichStart = bldr.Length; break;
            }
            switch (end)
            {
            case IchPosition.LateInHyperlink: ichEnd = 4; break;

            case IchPosition.EndOfString:
            case IchPosition.EndOfHyperlink: ichEnd = bldr.Length; break;
            }
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Top)).Return(ichStart);
            selHelper.Stub(selH => selH.GetIch(SelectionHelper.SelLimitType.Bottom)).Return(ichEnd);
            selHelper.Stub(selH => selH.IsRange).Return(ichStart != ichEnd);
        }
Ejemplo n.º 2
0
        // Generate a suitable string representation of a WfiGloss.
        // Todo: finish implementing (add the gloss!)
        static internal ITsString MakeGlossStringRep(IWfiGloss wg, FdoCache fdoCache, bool fUseStyleSheet)
        {
            ITsStrBldr tsb = TsStrBldrClass.Create();
            var        wa  = wg.Owner as IWfiAnalysis;

            var category = wa.CategoryRA;

            if (category != null)
            {
                ITsString tssPos = category.Abbreviation.get_String(fdoCache.DefaultAnalWs);
                tsb.Replace(0, 0, tssPos.Text,
                            PartOfSpeechTextProperties(fdoCache, false, fUseStyleSheet));
            }
            else
            {
                tsb.Replace(0, 0, ksMissingString,
                            PartOfSpeechTextProperties(fdoCache, false, fUseStyleSheet));
            }
            tsb.Replace(tsb.Length, tsb.Length, " ", null);
            tsb.Replace(tsb.Length, tsb.Length,
                        wg.Form.get_String(fdoCache.DefaultAnalWs).Text,
                        GlossTextProperties(fdoCache, false, fUseStyleSheet));

            //indent
            tsb.Replace(0, 0, "    ", null);
            return(tsb.GetString());
        }
Ejemplo n.º 3
0
        public void CreateFromStringRep_BT_withBrackets()
        {
            CheckDisposed();
            SetupBackTrans();

            // Setup expected results for the footnote
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                       (int)FwTextPropVar.ktpvDefault, m_vernWs);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Text in <brackets>", propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      null);
            m_footnotePara.Contents.UnderlyingTsString = bldr.GetString();

            // ... and now set up the expected results for the back translations of the footnote.
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsEs, "Spanish BT in <brackets>", null);
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsDe, "German BT in <brackets>", null);

            // Define text representation and create a footnote from it.
            string footnoteRep = @"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                                 @"<RUN WS='fr'>Text in &lt;brackets&gt;</RUN>" +
                                 @"<TRANS WS='es'><RUN WS='es'>Spanish BT in &lt;brackets&gt;</RUN></TRANS>" +
                                 @"<TRANS WS='de'><RUN WS='de'>German BT in &lt;brackets&gt;</RUN></TRANS></P></FN>";
            StFootnote footnote = StFootnote.CreateFromStringRep(m_book,
                                                                 (int)ScrBook.ScrBookTags.kflidFootnotes, footnoteRep, 0, "Note Marker");

            CompareFootnote(footnote);
        }
Ejemplo n.º 4
0
        public void CreateFromStringRep_twoParas()
        {
            CheckDisposed();

            ITsStrBldr bldr = m_footnotePara.Contents.UnderlyingTsString.GetBldr();

            bldr.Replace(0, 0, "Paragraph One", null);
            m_footnotePara.Contents.UnderlyingTsString = bldr.GetString();

            // create second para
            StTxtPara para = new StTxtPara();

            m_footnote.ParagraphsOS.Append(para);
            para.StyleRules = StyleUtils.ParaStyleTextProps("Note Exegesis Paragraph");
            bldr            = TsStrBldrClass.Create();
            bldr.Replace(0, 0, "Paragraph Two", StyleUtils.CharStyleTextProps("Foreign", m_wsUr));
            para.Contents.UnderlyingTsString = bldr.GetString();

            string footnoteRep = @"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                                 @"<RUN WS='fr'>Paragraph One</RUN></P><P><PS>Note Exegesis Paragraph</PS>" +
                                 @"<RUN WS='ur' CS='Foreign'>Paragraph Two</RUN></P></FN>";
            StFootnote footnote = StFootnote.CreateFromStringRep(m_book,
                                                                 (int)ScrBook.ScrBookTags.kflidFootnotes, footnoteRep, 0, "Note Marker");

            CompareFootnote(footnote);
        }
Ejemplo n.º 5
0
        public void CreateFromStringRep_twoCharStylePara()
        {
            CheckDisposed();

            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                       (int)FwTextPropVar.ktpvDefault,
                                       m_vernWs);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      "Emphasis");
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Test Text", propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      null);
            bldr.Replace(bldr.Length, bldr.Length, "No char style",
                         propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      "Quoted Text");
            bldr.Replace(bldr.Length, bldr.Length, "Ahh!!!!!!",
                         propsBldr.GetTextProps());
            m_footnotePara.Contents.UnderlyingTsString = bldr.GetString();

            string footnoteRep = @"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                                 @"<RUN WS='fr' CS='Emphasis'>Test Text</RUN><RUN WS='fr'>No char style</RUN>" +
                                 "<RUN WS='fr' CS='Quoted Text'>Ahh!!!!!!</RUN></P></FN>";
            StFootnote footnote = StFootnote.CreateFromStringRep(m_book,
                                                                 (int)ScrBook.ScrBookTags.kflidFootnotes, footnoteRep, 0, "Note Marker");

            CompareFootnote(footnote);
        }
Ejemplo n.º 6
0
        public void GetTextRepresentation_twoParas()
        {
            CheckDisposed();

            m_footnotePara.Contents.UnderlyingTsString =
                m_strFact.MakeString("Paragraph One", m_vernWs);

            // create second para
            StTxtPara para = new StTxtPara();

            m_footnote.ParagraphsOS.Append(para);

            // Set the paragraph style
            para.StyleRules = StyleUtils.ParaStyleTextProps("Note Exegesis Paragraph");

            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Paragraph Two", StyleUtils.CharStyleTextProps(
                             "Foreign", m_wsUr));
            para.Contents.UnderlyingTsString = bldr.GetString();

            string result = m_footnote.GetTextRepresentation();

            Assert.AreEqual(@"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                            @"<RUN WS='fr'>Paragraph One</RUN></P><P><PS>Note Exegesis Paragraph</PS>" +
                            @"<RUN WS='ur' CS='Foreign'>Paragraph Two</RUN></P></FN>", result);
        }
Ejemplo n.º 7
0
        public void DisplayOrCreateEntry_EmptyString()
        {
            ITsStrBldr emptyString = TsStrBldrClass.Create();

            Cache.MainCacheAccessor.SetString(1, 2, emptyString.GetString());
            // We shouldn't get an exception if we call DisplayOrCreateEntry with an empty string
            LexEntryUi.DisplayOrCreateEntry(Cache, 1, 2, 3, 0, 0, null, null, null, null);
        }
Ejemplo n.º 8
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Makes the footnote marker.
        /// </summary>
        /// <param name="markerWS">The WS of the marker</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public ITsStrBldr MakeFootnoteMarker(int markerWS)
        {
            // create a TsString to hold the marker
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            strBldr.Replace(0, 0, MarkerAsString, StyleUtils.CharStyleTextProps(ScrStyleNames.FootnoteMarker, markerWS));
            return(strBldr);
        }
Ejemplo n.º 9
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the context-sensitive string for the given guid. Usually this information comes
        /// from the page info.
        /// </summary>
        /// <param name="bstrGuid">String representation of a guid that can be interpreted as
        /// a context-sensitive type of info</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public override ITsString GetStrForGuid(string bstrGuid)
        {
            CheckDisposed();

            Guid guid = MiscUtils.GetGuidFromObjData(bstrGuid);

            ITsString tss = null;

            if (guid == HeaderFooterVc.PageNumberGuid)
            {
                tss = PageNumber;
            }
            else if (guid == HeaderFooterVc.FirstReferenceGuid)
            {
                tss = FirstReference;
            }
            else if (guid == HeaderFooterVc.LastReferenceGuid)
            {
                tss = LastReference;
            }
            else if (guid == HeaderFooterVc.PublicationTitleGuid)
            {
                tss = PublicationTitle;
            }
            else if (guid == HeaderFooterVc.PrintDateGuid)
            {
                tss = PrintDate;
            }
            else if (guid == HeaderFooterVc.PageReferenceGuid)
            {
                tss = PageReference;
            }
            else if (guid == HeaderFooterVc.TotalPagesGuid)
            {
                tss = TotalPages;
            }
            else if (guid == HeaderFooterVc.DivisionNameGuid)
            {
                tss = DivisionName;
            }
            else if (guid == HeaderFooterVc.ProjectNameGuid)
            {
                tss = ProjectName;
            }
            else if (guid == HeaderFooterVc.BookNameGuid)
            {
                tss = BookName;
            }

            if (tss == null)
            {
                ITsStrBldr strBuilder = TsStrBldrClass.Create();
                strBuilder.SetIntPropValues(0, 0, (int)FwTextPropType.ktptWs, 0, m_wsDefault);
                tss = strBuilder.GetString();
            }
            return(tss);
        }
Ejemplo n.º 10
0
        void AddSeparatorLine()
        {
            //review
            ITsStrBldr builder = TsStrBldrClass.Create();

            builder.Replace(0, 0, "-------", null);
            HvoTssComboItem newItem = new HvoTssComboItem(-1, builder.GetString());             //hack todo

            m_combo.Items.Add(newItem);
        }
Ejemplo n.º 11
0
        public void TsStringsSame()
        {
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            strBldr.Replace(0, 0, "Test", TsPropsFactoryClass.Create().MakeProps(null, 5, 0));
            string s;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(strBldr.GetString(),
                                                           strBldr.GetString(), out s));
        }
Ejemplo n.º 12
0
        protected ITsString MakeSimpleString(String str)
        {
            ITsStrBldr   builder = TsStrBldrClass.Create();
            ITsPropsBldr bldr    = TsPropsBldrClass.Create();

            bldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                  (int)FwTextPropVar.ktpvMilliPoint, s_baseFontSize * 800);
            bldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Arial");
            builder.Replace(0, 0, str, bldr.GetTextProps());
            return(builder.GetString());
        }
Ejemplo n.º 13
0
        public void TestLoad_ObjectSequenceFilterWithSubItems()
        {
            CheckDisposed();

            // Set up a filter
            CmFilter filter = new CmFilter();

            Cache.LangProject.FiltersOC.Add(filter);
            filter.ClassId = ScrScriptureNote.kClassId;
            // We will filter ScrScriptureNotes on the Categories field.
            filter.ColumnInfo = ScrScriptureNote.kclsidScrScriptureNoteString + "," +
                                ((int)ScrScriptureNote.ScrScriptureNoteTags.kflidCategories).ToString();
            filter.ShowPrompt = 1;
            CmRow row = new CmRow();

            filter.RowsOS.Append(row);
            CmCell cell = new CmCell();

            row.CellsOS.Append(cell);
            // Now specify the matching criteria for this filter cell
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Matches  +subitems",
                         SIL.FieldWorks.Common.FwUtils.StyleUtils.CharStyleTextProps(null, Cache.DefaultUserWs));
            StringUtils.InsertOrcIntoPara(m_inMemoryCache.m_categoryDiscourse.Guid,
                                          FwObjDataTypes.kodtNameGuidHot, bldr, 8, 8, Cache.DefaultUserWs);
            cell.Contents.UnderlyingTsString = bldr.GetString();

            // Set up mocked ChooserDlg to expect to be called with the default category of Discourse (from
            // filter cell criteria defined above) but return Grammar category.
            m_mockedChooserDlg.ExpectAndReturn("GetPossibility", m_inMemoryCache.m_categoryGrammar.Hvo,
                                               new object[] { m_scr.NoteCategoriesOA, m_inMemoryCache.m_categoryDiscourse.Hvo });

            // Construct a handler to apply the above filter.
            filter.UserView            = m_userView;
            filter.PossibilitySupplier = (ICmPossibilitySupplier)m_mockedChooserDlg.MockInstance;
            FilteredSequenceHandler handler = new FilteredSequenceHandler(Cache,
                                                                          ScrBookAnnotations.kClassId, -42, filter, null, m_userView);

            // Now test the Load method
            // CacheVecProp() should be called with an array of HVOs representing all the Grammar notes,
            // including those that refer to sub-items of the main Grammar category.
            m_mockedDataAccess.Expect("CacheVecProp",
                                      new object[] { m_annotationsGen.Hvo, -94, new int[] { m_note2a.Hvo, m_note2b.Hvo, m_note3.Hvo }, 3 });
            handler.Load(m_annotationsGen.Hvo, -94, -1, (IVwCacheDa)m_mockedDataAccess.MockInstance);
            m_mockedDataAccess.Verify();
            m_mockedChooserDlg.Verify();

            // Make sure the newly-selected object (i.e., the Grammar category) has been stored as the
            // filter criteria (for next time).
            StringUtils.InsertOrcIntoPara(m_inMemoryCache.m_categoryGrammar.Guid,
                                          FwObjDataTypes.kodtNameGuidHot, bldr, 8, 9, Cache.DefaultUserWs);
            AssertEx.AreTsStringsEqual(bldr.GetString(), cell.Contents.UnderlyingTsString);
        }
Ejemplo n.º 14
0
        public void GetKeyTermFromTSS_EndsWithORC()
        {
            ITsStrBldr tsb = TsStrBldrClass.Create();

            tsb.Replace(0, 0, "angel", StyleUtils.CharStyleTextProps("Emphasis", Cache.DefaultVernWs));
            tsb.ReplaceTsString(5, 5, TsStringUtils.CreateOrcFromGuid(new Guid(),
                                                                      FwObjDataTypes.kodtOwnNameGuidHot, Cache.DefaultUserWs));
            // We expect the ORC to be removed from the end of the input ITsString.
            Assert.AreEqual("angel", TsStringUtils.GetCleanTextFromTsString(tsb.GetString(),
                                                                            m_stylesToRemove, true, Cache.LanguageWritingSystemFactoryAccessor));
        }
Ejemplo n.º 15
0
        public void TsStringsTwoEmpty_NoProps()
        {
            CheckDisposed();
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            strBldr.Replace(0, 0, "", null);
            string s;

            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(strBldr.GetString(),
                                                           strBldr.GetString(), out s));
        }
Ejemplo n.º 16
0
        public void BuildObjectMatchCriteria_NoDefaultIncludeSubitemsExcludeEmpty()
        {
            m_cell.SetObjectMatchCriteria(null, true, false);

            //verify the result
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Matches +subitems", StyleUtils.CharStyleTextProps(null, Cache.DefaultUserWs));

            AssertEx.AreTsStringsEqual(bldr.GetString(), m_cell.Contents);
        }
Ejemplo n.º 17
0
        void AddSeparatorLine()
        {
            //review
            ITsStrBldr builder = TsStrBldrClass.Create();

            builder.Replace(0, 0, "-------", null);
            builder.SetIntPropValues(0, builder.Length, (int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_cache.DefaultUserWs);
            HvoTssComboItem newItem = new HvoTssComboItem(-1, builder.GetString());             //hack todo

            m_combo.Items.Add(newItem);
        }
Ejemplo n.º 18
0
        protected ITsString MakeSimpleString(String str)
        {
            ITsStrBldr   builder = TsStrBldrClass.Create();
            ITsPropsBldr bldr    = TsPropsBldrClass.Create();

            bldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_cache.DefaultUserWs);
            bldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                  (int)FwTextPropVar.ktpvMilliPoint, s_baseFontSize * 800);
            bldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, MiscUtils.StandardSansSerif);
            builder.Replace(0, 0, str, bldr.GetTextProps());
            return(builder.GetString());
        }
Ejemplo n.º 19
0
        public void TryGetObject_ORCWithSameProps_ObjData()
        {
            IPunctuationForm pf   = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create();
            ITsStrBldr       bldr = TsStrBldrClass.Create();

            TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtNameGuidHot, bldr, 0, 0, Cache.DefaultVernWs);
            pf.Form = bldr.GetString();
            IPunctuationForm pfExisting;
            ITsString        tssOrcness = bldr.GetString();

            Assert.IsTrue(m_repo.TryGetObject(tssOrcness, out pfExisting));
            Assert.AreEqual(pf, pfExisting);
        }
Ejemplo n.º 20
0
        public void TryGetObject_PlainPunctString_NotExists_ORCTableNotEmpty()
        {
            IPunctuationForm pf   = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create();
            ITsStrBldr       bldr = TsStrBldrClass.Create();

            TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtNameGuidHot, bldr, 0, 0, Cache.DefaultVernWs);
            pf.Form = bldr.GetString();

            IPunctuationForm pfDummy;
            ITsString        tssPunc = Cache.TsStrFactory.MakeString(".", Cache.DefaultVernWs);

            Assert.IsFalse(m_repo.TryGetObject(tssPunc, out pfDummy));
        }
Ejemplo n.º 21
0
        public void NullStringDiffersFromTsString()
        {
            CheckDisposed();
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            strBldr.Replace(0, 0, "Test", null);
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(strBldr.GetString(), null,
                                                            out s));
            Assert.AreEqual("TsStrings differ.\n\tExpected <Test>, but was <null>.", s,
                            "Got incorrect explanation of difference");
        }
Ejemplo n.º 22
0
        public void NullStringDiffersFromTsString()
        {
            ITsStrBldr      strBldr   = TsStrBldrClass.Create();
            ITsPropsFactory propsFact = TsPropsFactoryClass.Create();

            strBldr.Replace(0, 0, "Test", propsFact.MakeProps(null, 5, 0));
            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(strBldr.GetString(), null,
                                                            out s));
            Assert.AreEqual("TsStrings differ." + Environment.NewLine + "\tExpected <Test>, but was <null>.", s,
                            "Got incorrect explanation of difference");
        }
Ejemplo n.º 23
0
        public void IsValidTSS_TooLong()
        {
            StringBuilder str = new StringBuilder();

            for (int i = 0; i < 600; i++)
            {
                str.Append('A');
            }
            ITsStrBldr tsb = TsStrBldrClass.Create();

            tsb.Replace(0, 0, str.ToString(), StyleUtils.CharStyleTextProps("Emphasis", Cache.DefaultVernWs));
            Assert.IsFalse(ReflectionHelper.GetBoolResult(m_ktVwWrapper, "IsValidTSS", tsb.GetString()));
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates the categories.
        /// </summary>
        /// <param name="cache">The cache.</param>
        /// <param name="ws">The writing system for setting the category names.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        internal static ICmPossibilityList CreateCategories(FdoCache cache, int ws)
        {
            ICmPossibilityList list = cache.LangProject.TranslatedScriptureOA.NoteCategoriesOA;

            list.PossibilitiesOS.Clear();
            var possFactory = cache.ServiceLocator.GetInstance <ICmPossibilityFactory>();

            // Initialize text.
            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();

            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, ws);
            ITsStrBldr tsStrBldr = TsStrBldrClass.Create();

            // Set possibilities on top level--"Level 1a"
            ICmPossibility possibility1a = possFactory.Create();

            list.PossibilitiesOS.Add(possibility1a);
            tsStrBldr.ReplaceRgch(0, 0, "Level 1a", 8, ttpBldr.GetTextProps());
            possibility1a.Name.set_String(ws, tsStrBldr.GetString());

            // Add another on top level--"Level 1b"
            ICmPossibility possibility1b = possFactory.Create();

            list.PossibilitiesOS.Add(possibility1b);
            tsStrBldr.ReplaceRgch(0, tsStrBldr.Length, "Level 1b", 8, ttpBldr.GetTextProps());
            possibility1b.Name.set_String(ws, tsStrBldr.GetString());

            // Add possibilities on second level under "Level 1b"--"Level 2a"
            ICmPossibility subPossibility2a = possFactory.Create();

            possibility1b.SubPossibilitiesOS.Add(subPossibility2a);
            tsStrBldr.ReplaceRgch(0, tsStrBldr.Length, "Level 2a, parent is 1b", 22, ttpBldr.GetTextProps());
            subPossibility2a.Name.set_String(ws, tsStrBldr.GetString());

            // Add "Level 2b" under "Level 1b"
            ICmPossibility subPossibility2b = possFactory.Create();

            possibility1b.SubPossibilitiesOS.Add(subPossibility2b);
            tsStrBldr.ReplaceRgch(0, tsStrBldr.Length, "Level 2b, parent is 1b", 22, ttpBldr.GetTextProps());
            subPossibility2b.Name.set_String(ws, tsStrBldr.GetString());

            // Add "Level 3" under "Level 2b"
            ICmPossibility subSubPossibility3 = possFactory.Create();

            subPossibility2b.SubPossibilitiesOS.Add(subSubPossibility3);
            tsStrBldr.ReplaceRgch(0, tsStrBldr.Length, "Level 3, parent is 2b", 21, ttpBldr.GetTextProps());
            subSubPossibility3.Name.set_String(ws, tsStrBldr.GetString());

            return(list);
        }
Ejemplo n.º 25
0
        public void UserPromptChangeWSWhenPasting()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();

            Options.ShowEmptyParagraphPromptsSetting = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("IsCompositionInProgress", false);
            DynamicMock vwsel       = new DynamicMock(typeof(IVwSelection));
            IVwRootBox  mockRootbox = (IVwRootBox)rootb.MockInstance;

            vwsel.SetupResult("RootBox", mockRootbox);
            vwsel.SetupResult("CLevels", 4, typeof(bool));
            vwsel.Ignore("AllTextSelInfo");
#if DEBUG
            vwsel.SetupResult("IsValid", true);
#endif

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache,
                                               m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox);

            // set up the text to paste - will be TE2ST with vernacular WS
            int             ws       = m_inMemoryCache.Cache.DefaultVernWs;
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, ws, 0);
            ITsStrBldr      bldr     = TsStrBldrClass.Create();
            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssVal = bldr.GetString();

            // Now simulate the user pasting over the user prompt
            stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo,
                            SimpleRootSite.kTagUserPrompt, 0, tssVal);

            // verify that the text is in the paragraph, that there is no longer a user
            // prompt, and that the ws changed but the character formatting survives.
            bldr = tssVal.GetBldr();
            bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString);

            m_vwenvMock.Verify();
        }
Ejemplo n.º 26
0
        public void BuildObjectMatchCriteria_WithDefaultIncludeSubitemsIncludeEmpty()
        {
            m_cell.SetObjectMatchCriteria(m_categoryGrammar, true, true);

            //verify the result
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Empty or Matches  +subitems",
                         StyleUtils.CharStyleTextProps(null, Cache.DefaultUserWs));
            TsStringUtils.InsertOrcIntoPara(m_categoryGrammar.Guid,
                                            FwObjDataTypes.kodtNameGuidHot, bldr, 17, 17, Cache.DefaultUserWs);

            AssertEx.AreTsStringsEqual(bldr.GetString(), m_cell.Contents);
        }
Ejemplo n.º 27
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);
            }
        }
Ejemplo n.º 28
0
        public void TryGetObject_ORCWithDifferentProps_ObjData()
        {
            IPunctuationForm pf   = Cache.ServiceLocator.GetInstance <IPunctuationFormFactory>().Create();
            ITsStrBldr       bldr = TsStrBldrClass.Create();

            TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtNameGuidHot, bldr, 0, 0, Cache.DefaultVernWs);
            pf.Form = bldr.GetString();
            IPunctuationForm pfDummy;

            // Replace the ORC in the builder with a different ORC
            TsStringUtils.InsertOrcIntoPara(Guid.NewGuid(), FwObjDataTypes.kodtOwnNameGuidHot, bldr, 0, 1, Cache.DefaultVernWs);
            ITsString tssOrcness = bldr.GetString();

            Assert.IsFalse(m_repo.TryGetObject(tssOrcness, out pfDummy));
        }
Ejemplo n.º 29
0
 /// <summary>
 /// If this is the first segment in the group and NOT the first group, check for the possibility that
 /// there was no segment to attach the previous group's BTs to. I think this can only
 /// happen for the first group. Put the orphan BT at the start of this segment so it isn't lost.
 /// </summary>
 /// <param name="igroup"></param>
 /// <param name="iParaSeg"></param>
 /// <param name="tssFt"></param>
 /// <returns></returns>
 private ITsString InsertOrphanBtFromPreviousGroup(int igroup, int iParaSeg, ITsString tssFt)
 {
     if (iParaSeg == 0 && igroup > 0 && m_segGroups[igroup - 1].ParaSegs.Count == 0)
     {
         ITsStrBldr bldr      = TsStrBldrClass.Create();
         SegGroup   prevGroup = m_segGroups[igroup - 1];
         for (int j = 0; j < prevGroup.BtSegs.Count; j++)
         {
             AppendWithOptionalSpace(bldr, prevGroup.BtSegs[j].Text);
         }
         AppendWithOptionalSpace(bldr, tssFt);
         tssFt = bldr.GetString();
     }
     return(tssFt);
 }
Ejemplo n.º 30
0
        public void BuildObjectMatchCriteria_WithDefaultExcludeSubitemsIncludeEmpty()
        {
            CheckDisposed();

            m_cell.BuildObjectMatchCriteria(m_inMemoryCache.m_categoryGrammar.Hvo, false, true);

            //verify the result
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Empty or Matches ", StyleUtils.CharStyleTextProps(null, Cache.DefaultUserWs));
            StringUtils.InsertOrcIntoPara(m_inMemoryCache.m_categoryGrammar.Guid,
                                          FwObjDataTypes.kodtNameGuidHot, bldr, bldr.Length,
                                          bldr.Length, Cache.DefaultUserWs);

            AssertEx.AreTsStringsEqual(bldr.GetString(), m_cell.Contents.UnderlyingTsString);
        }