Exemple #1
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();
        }
Exemple #2
0
        public void UserPromptChangeWSWhenTyping()
        {
            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);
            ITsStrFactory tsf  = TsStrFactoryClass.Create();
            ITsString     tssVal;
            tssVal = tsf.MakeString("TEST", m_inMemoryCache.Cache.DefaultVernWs);

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

            // verify that the text is in the paragraph and that there is no longer a user prompt.
            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();
            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            ITsStrBldr bldr = TsStrBldrClass.Create();
            bldr.Replace(0, 0, "TEST", ttpBldr.GetTextProps());
            string diff;
            Assert.IsTrue(TsStringHelper.TsStringsAreEqual(bldr.GetString(),
                                                           para.Contents.UnderlyingTsString, out diff), diff);

            m_vwenvMock.Verify();
        }
Exemple #3
0
        public void Setup()
        {
            CheckDisposed();
            m_ode  = new DynamicMock(typeof(IOleDbEncap));
            m_odde = new DynamicMock(typeof(IVwOleDbDa));
            m_mdc  = new DynamicMock(typeof(IFwMetaDataCache));
            m_odc  = new DynamicMock(typeof(IOleDbCommand));
            m_odc.Ignore("ExecCommand");
            m_ode.SetupResult("CreateCommand", null,
                              new string[] { "SIL.FieldWorks.Common.COMInterfaces.IOleDbCommand&" },
                              new object[] { m_odc.MockInstance });

            m_cacheBase = new CacheBase((IFwMetaDataCache)m_mdc.MockInstance);

            if (m_fdoCache != null)
            {
                m_fdoCache.Dispose();
            }
            m_fdoCache = new DummyFdoCache((IOleDbEncap)m_ode.MockInstance,
                                           (IFwMetaDataCache)m_mdc.MockInstance, (IVwOleDbDa)m_odde.MockInstance,
                                           m_cacheBase);
        }
Exemple #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <param name="bookStart"></param>
        /// <param name="iBookStart"></param>
        /// <param name="sectionStart"></param>
        /// <param name="iSecStart"></param>
        /// <param name="paraStart"></param>
        /// <param name="iParaStart"></param>
        /// <param name="ichStart"></param>
        /// <param name="setupForHeadingStart"></param>
        /// <param name="bookEnd"></param>
        /// <param name="iBookEnd"></param>
        /// <param name="sectionEnd"></param>
        /// <param name="iSecEnd"></param>
        /// <param name="paraEnd"></param>
        /// <param name="iParaEnd"></param>
        /// <param name="ichEnd"></param>
        /// <param name="setupForHeadingEnd"></param>
        /// ------------------------------------------------------------------------------------
        public void SetupRangeSelection(IScrBook bookStart, int iBookStart, IScrSection sectionStart,
                                        int iSecStart, IStTxtPara paraStart, int iParaStart, int ichStart,
                                        bool setupForHeadingStart, IScrBook bookEnd, int iBookEnd, IScrSection sectionEnd,
                                        int iSecEnd, IStTxtPara paraEnd, int iParaEnd, int ichEnd, bool setupForHeadingEnd)
        {
            CheckDisposed();

            DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));

            fakeSelHelper.SetupResult("NumberOfLevels", 4);
            // Setup the anchor
            SelLevInfo[] topInfo = new SelLevInfo[4];
            topInfo[0].tag  = StTextTags.kflidParagraphs;
            topInfo[0].ihvo = iParaStart;
            topInfo[0].hvo  = paraStart.Hvo;
            topInfo[1].tag  = setupForHeadingStart ? ScrSectionTags.kflidHeading :
                              ScrSectionTags.kflidContent;
            topInfo[1].ihvo = 0;
            topInfo[1].hvo  = setupForHeadingStart ? sectionStart.HeadingOA.Hvo :
                              sectionStart.ContentOA.Hvo;
            topInfo[2].tag  = ScrBookTags.kflidSections;
            topInfo[2].ihvo = iSecStart;
            topInfo[2].hvo  = sectionStart.Hvo;
            topInfo[3].tag  = ScriptureTags.kflidScriptureBooks;
            topInfo[3].ihvo = iBookStart;
            topInfo[3].hvo  = bookStart.Hvo;

            // Setup the end
            SelLevInfo[] bottomInfo = new SelLevInfo[4];
            bottomInfo[0].tag  = StTextTags.kflidParagraphs;
            bottomInfo[0].ihvo = iParaEnd;
            bottomInfo[0].hvo  = paraEnd.Hvo;
            bottomInfo[1].tag  = setupForHeadingEnd ? ScrSectionTags.kflidHeading :
                                 ScrSectionTags.kflidContent;
            bottomInfo[1].ihvo = 0;
            bottomInfo[1].hvo  = setupForHeadingEnd ? sectionEnd.HeadingOA.Hvo :
                                 sectionEnd.ContentOA.Hvo;
            bottomInfo[2].tag  = ScrBookTags.kflidSections;
            bottomInfo[2].ihvo = iSecEnd;
            bottomInfo[2].hvo  = sectionEnd.Hvo;
            bottomInfo[3].tag  = ScriptureTags.kflidScriptureBooks;
            bottomInfo[3].ihvo = iBookEnd;
            bottomInfo[3].hvo  = bookEnd.Hvo;

            fakeSelHelper.SetupResult("LevelInfo", topInfo);
            fakeSelHelper.SetupResult("IchAnchor", ichStart);
            fakeSelHelper.SetupResult("IchEnd", ichEnd);
            fakeSelHelper.SetupResult("IsValid", true);
            fakeSelHelper.SetupResult("AssocPrev", false);
            fakeSelHelper.Ignore("get_IsRange");
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Anchor);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.Bottom);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.End);
            fakeSelHelper.SetupResultForParams("GetIch", ichStart,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
                                               SelectionHelper.SelLimitType.Bottom);
            m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance;
        }