예제 #1
0
        public void GetSetClipboard()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition enWs;

            wsManager.GetOrSet("en", out enWs);
            int wsEng = enWs.Handle;

            CoreWritingSystemDefinition swgWs;

            wsManager.GetOrSet("swg", out swgWs);
            int wsSwg = swgWs.Handle;

            var incStrBldr = TsStringUtils.MakeIncStrBldr();

            incStrBldr.AppendTsString(TsStringUtils.MakeString("Gogomer ", wsSwg));
            incStrBldr.AppendTsString(TsStringUtils.MakeString("cucumber", wsEng));
            EditingHelper.SetTsStringOnClipboard(incStrBldr.GetString(), false, wsManager);

            var tss = m_basicView.EditingHelper.GetTsStringFromClipboard(wsManager);

            Assert.IsNotNull(tss, "Couldn't get TsString from clipboard");
            Assert.AreEqual(2, tss.RunCount);
            Assert.AreEqual("Gogomer ", tss.get_RunText(0));
            Assert.AreEqual("cucumber", tss.get_RunText(1));

            var newDataObj = ClipboardUtils.GetDataObject();

            Assert.IsNotNull(newDataObj, "Couldn't get DataObject from clipboard");
            Assert.AreEqual("Gogomer cucumber", newDataObj.GetData("Text"));
        }
예제 #2
0
        public void SetTsStringOnClipboard_UsesNFC()
        {
            var wsManager = new WritingSystemManager();
            CoreWritingSystemDefinition enWs;

            wsManager.GetOrSet("en", out enWs);
            int wsEng         = enWs.Handle;
            var originalInput = "\x7a7a\x60f3\x79d1\x5b78\x0020\xd558";
            var input         = originalInput.Normalize(NormalizationForm.FormD);

            Assert.That(originalInput, Is.Not.EqualTo(input));             // make sure input is NOT NFC
            var tss = TsStringUtils.MakeString(input, wsEng);

            EditingHelper.SetTsStringOnClipboard(tss, false, wsManager);
            var newDataObj = ClipboardUtils.GetDataObject();

            Assert.IsNotNull(newDataObj, "Couldn't get DataObject from clipboard");
            Assert.AreEqual(originalInput, newDataObj.GetData("Text"));
        }
        public void PasteMultiParasIntoFootnote()
        {
            IScrBook    book    = AddBookToMockedScripture(1, "Genesis");
            IScrSection section = AddSectionToMockedBook(book);
            IStTxtPara  para    = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph);

            AddRunToMockedPara(para, "Scripture text", Cache.DefaultVernWs);
            IStFootnote footnote1       = AddFootnote(book, para, 9, "footnote 1");
            int         footnote1Length = ((IStTxtPara)footnote1.ParagraphsOS[0]).Contents.Length;

            m_hvoRoot = Cache.LangProject.TranslatedScriptureOA.Hvo;

            ShowForm(DummyBasicViewVc.DisplayType.kNormal);
            IVwRootBox rootBox = m_basicView.RootBox;

            ITsStrBldr strBldr = TsStrBldrClass.Create();

            strBldr.Replace(0, 0, "New heading line1", StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));
            strBldr.Replace(strBldr.Length, strBldr.Length, Environment.NewLine,
                            StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalParagraph));
            strBldr.Replace(strBldr.Length, strBldr.Length, "heading line2" + Environment.NewLine + "New heading line3",
                            StyleUtils.CharStyleTextProps(null, Cache.DefaultVernWs));

            EditingHelper.SetTsStringOnClipboard(strBldr.GetString(), false, Cache.WritingSystemFactory);

            // Make selection at the end of the footnote
            Assert.IsNotNull(rootBox.MakeSimpleSel(false, true, false, true));

            // Paste contents of clipboard at current selection.
            m_basicView.EditingHelper.PasteClipboard();

            // We expect that the footnote will only have one paragraph with the extra paragraphs
            // concatenated, separated with spaces.
            Assert.AreEqual(1, footnote1.ParagraphsOS.Count);
            Assert.AreEqual("footnote 1New heading line1 heading line2 New heading line3",
                            ((IStTxtPara)footnote1.ParagraphsOS[0]).Contents.Text);
        }