Example #1
0
        public void MergeWritingSystemWithStyleDefnForToWs_DoesNotConvertStyleDefinition()
        {
            CoreWritingSystemDefinition fromWs;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-NO", true, false, out fromWs);
            CoreWritingSystemDefinition toWs;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-SO", true, false, out toWs);
            EnsureAnalysisWs(new[] { fromWs, toWs });

            var style1 = Cache.ServiceLocator.GetInstance <IStStyleFactory>().Create();

            Cache.LangProject.StylesOC.Add(style1);
            var fontOverrides = new Dictionary <int, FontInfo>();
            var fontOverride  = new FontInfo();

            fontOverride.m_italic.ExplicitValue = true;
            fontOverrides[fromWs.Handle]        = fontOverride;
            fontOverride = new FontInfo();
            fontOverride.m_bold.ExplicitValue = true;
            fontOverrides[toWs.Handle]        = fontOverride;
            var bldr = TsStringUtils.MakePropsBldr();

            BaseStyleInfo.SaveFontOverridesToBuilder(fontOverrides, bldr);
            style1.Rules = bldr.GetTextProps();
            m_actionHandler.EndUndoTask();
            UndoableUnitOfWorkHelper.Do("doit", "undoit", m_actionHandler,
                                        () => WritingSystemServices.MergeWritingSystems(Cache, fromWs, toWs));
            var styleInfo    = new BaseStyleInfo(style1);
            var overrideInfo = styleInfo.OverrideCharacterStyleInfo(toWs.Handle);

            Assert.IsNotNull(overrideInfo);
            Assert.That(overrideInfo.Bold.Value, Is.True);
            Assert.That(overrideInfo.Italic.ValueIsSet, Is.False);
        }
Example #2
0
        public void MergeWritingSystem_ConvertsMultiStrings()
        {
            var entry1 = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create();
            CoreWritingSystemDefinition fromWs;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-NO", true, false, out fromWs);
            CoreWritingSystemDefinition toWs;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-SO", true, false, out toWs);
            EnsureAnalysisWs(new [] { fromWs, toWs });
            var sense1 = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create();

            entry1.SensesOS.Add(sense1);
            // Sense1 should be dirty: it has a gloss in the changing WS.
            sense1.Gloss.set_String(fromWs.Handle, TsStringUtils.MakeString("whatever", fromWs.Handle));
            m_actionHandler.EndUndoTask();
            UndoableUnitOfWorkHelper.Do("doit", "undoit", m_actionHandler,
                                        () => WritingSystemServices.MergeWritingSystems(Cache, fromWs, toWs));
            Assert.That(sense1.Gloss.get_String(toWs.Handle).Text, Is.EqualTo("whatever"));
        }
Example #3
0
        public void MergeWritingSystem_ConvertsLiftResidue()
        {
            CoreWritingSystemDefinition fromWs;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-NO", true, false, out fromWs);
            CoreWritingSystemDefinition toWs;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-SO", true, false, out toWs);
            EnsureAnalysisWs(new[] { fromWs, toWs });

            var entry1 = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create();

            entry1.LiftResidue =
                "<lift-residue id=\"aj1_8ef13061-21ae-480f-b3a9-6b694e1ec3c4\" dateCreated=\"2005-11-09T02:57:45Z\" dateModified=\"2010-07-03T08:15:00Z\"><field type=\"Source Language\">"
                + "<form lang=\"en\"><text>Proto-Tai</text></form>"
                + "<form lang=\"en-NO\"><text>¥ポ¥ᄃヒ¥マᄚ│ᆵᆳ</text></form>"
                + "</field>"
                + "</lift-residue>";

            m_actionHandler.EndUndoTask();
            UndoableUnitOfWorkHelper.Do("doit", "undoit", m_actionHandler,
                                        () => WritingSystemServices.MergeWritingSystems(Cache, fromWs, toWs));
            Assert.That(entry1.LiftResidue.Contains("lang=\"en-SO\""));
        }