Esempio n. 1
0
        public void LoadParatextMappings_Normal()
        {
            if (ScriptureProvider.VersionInUse >= new Version(8, 0))
            {
                Assert.Ignore("This test uses data that is only valid for Paratext7. The test fails with Paratext8 installed.");
            }
            Unpacker.UnPackParatextTestProjects();

            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ParatextScrProj = "KAM";
            ParatextHelper.LoadProjectMappings(importSettings);

            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            // Test to see that the projects are set correctly
            Assert.AreEqual(44, mappingList.Count);

            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\c"].Domain);
            Assert.AreEqual(MarkerDomain.Default, mappingList[@"\v"].Domain);
            Assert.AreEqual(@"\f*", mappingList[@"\f"].EndMarker);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\tb2"].IsInUse);
        }
Esempio n. 2
0
        public void LoadParatextMappings_MarkMappingsInUse()
        {
            if (ScriptureProvider.VersionInUse >= new Version(8, 0))
            {
                Assert.Ignore("This test uses data that is only valid for Paratext7. The test fails with Paratext8 installed.");
            }
            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ParatextScrProj = "TEV";
            ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main);

            Assert.NotNull(mappingList, "Setup Failure, no mapping list returned for the domain.");
            mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  null, null, true, ImportDomain.Main));
            mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false,
                                                  MappingTargetType.TEStyle, MarkerDomain.Default, "laughing",
                                                  "en", null, true, ImportDomain.Main));

            Unpacker.UnPackParatextTestProjects();

            ParatextHelper.LoadProjectMappings(importSettings);

            Assert.IsTrue(mappingList[@"\c"].IsInUse);
            Assert.IsTrue(mappingList[@"\p"].IsInUse);
            Assert.IsFalse(mappingList[@"\ipi"].IsInUse);
            Assert.IsFalse(mappingList[@"\hahaha"].IsInUse,
                           "In-use flag should have been cleared before re-scanning when the P6 project changed.");
            Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse,
                          "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT.");
        }
Esempio n. 3
0
        private void m_btnStyles_Click(object sender, EventArgs e)
        {
            bool fRTL = m_cache.WritingSystemFactory.get_EngineOrNull(m_cache.DefaultUserWs).RightToLeftScript;

            using (var dlg = new FwStylesDlg(null, m_cache, m_stylesheet as LcmStyleSheet,
                                             fRTL,
                                             m_cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript),
                                             m_stylesheet.GetDefaultBasedOnStyleName(),
                                             0, // customUserLevel
                                             m_app.MeasurementSystem,
                                             m_stylesheet.GetDefaultBasedOnStyleName(),
                                             String.Empty,
                                             0, // hvoRootObject
                                             m_app, m_helpTopicProvider))
            {
                dlg.ShowTEStyleTypes = false;
                dlg.CanSelectParagraphBackgroundColor = false;
                if (dlg.ShowDialog(this) == DialogResult.OK &&
                    ((dlg.ChangeType & StyleChangeType.DefChanged) > 0 ||
                     (dlg.ChangeType & StyleChangeType.Added) > 0 ||
                     (dlg.ChangeType & StyleChangeType.RenOrDel) > 0))
                {
                    m_app.Synchronize(SyncMsg.ksyncStyle);
                    LcmStyleSheet stylesheet = new LcmStyleSheet();
                    stylesheet.Init(m_cache, m_cache.LangProject.Hvo, LangProjectTags.kflidStyles);
                    m_stylesheet = stylesheet;
                }
                string stySel = null;
                if (m_cbStyle.SelectedItem != null)
                {
                    stySel = m_cbStyle.SelectedItem.ToString();
                }
                FillStylesCombo(stySel);
            }
        }
Esempio n. 4
0
 private void RunStyleDialog(string styleName)
 {
     using (var dlg = new FwStylesDlg(null, m_cache, m_stylesheet,
                                      m_cache.WritingSystemFactory.get_EngineOrNull(m_cache.DefaultUserWs).RightToLeftScript,
                                      m_cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript),
                                      m_stylesheet.GetDefaultBasedOnStyleName(),
                                      0,         // customUserLevel
                                      m_app.MeasurementSystem,
                                      styleName, //m_stylesheet.GetDefaultBasedOnStyleName(),
                                      styleName,
                                      0,         // hvoRootObject
                                      m_app, m_helpTopicProvider))
     {
         dlg.ShowTEStyleTypes = false;
         dlg.CanSelectParagraphBackgroundColor = false;
         if (dlg.ShowDialog(this) == DialogResult.OK && dlg.ChangeType != StyleChangeType.None)
         {
             m_app.Synchronize(SyncMsg.ksyncStyle);
             LcmStyleSheet stylesheet = new LcmStyleSheet();
             stylesheet.Init(m_cache, m_cache.LangProject.Hvo, LangProjectTags.kflidStyles);
             m_stylesheet            = stylesheet;
             m_masterRefreshRequired = true;
         }
     }
 }
Esempio n. 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FwApplyStyleDlg"/> class.
        /// </summary>
        /// <param name="rootSite">The root site.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="hvoStylesOwner">The hvo of the object which owns the style.</param>
        /// <param name="stylesTag">The "flid" in which the styles are owned.</param>
        /// <param name="normalStyleName">Name of the normal style.</param>
        /// <param name="customUserLevel">The custom user level.</param>
        /// <param name="paraStyleName">Name of the currently selected paragraph style.</param>
        /// <param name="charStyleName">Name of the currently selected character style.</param>
        /// <param name="hvoRootObject">The hvo of the root object in the current view.</param>
        /// <param name="app">The application.</param>
        /// <param name="helpTopicProvider">The help topic provider.</param>
        /// ------------------------------------------------------------------------------------
        public FwApplyStyleDlg(IVwRootSite rootSite, LcmCache cache, int hvoStylesOwner,
                               int stylesTag, string normalStyleName, int customUserLevel, string paraStyleName,
                               string charStyleName, int hvoRootObject, IApp app,
                               IHelpTopicProvider helpTopicProvider)
        {
            m_rootSite = rootSite;
            InitializeComponent();
            m_customUserLevel   = customUserLevel;
            m_helpTopicProvider = helpTopicProvider;
            m_paraStyleName     = paraStyleName;
            m_charStyleName     = charStyleName;

            // Cache is null in tests
            if (cache == null)
            {
                return;
            }

            m_cboTypes.SelectedIndex = 1;             // All Styles

            // Load the style information
            m_styleTable = new StyleInfoTable(normalStyleName,
                                              cache.ServiceLocator.WritingSystemManager);
            m_styleSheet = new LcmStyleSheet();
            m_styleSheet.Init(cache, hvoStylesOwner, stylesTag);
            m_styleListHelper = new StyleListBoxHelper(m_lstStyles);
            m_styleListHelper.ShowInternalStyles = false;
        }
Esempio n. 6
0
        public void ReadOnlySpaceAfterFootnoteMarker()
        {
            // Prepare the test by creating a footnote view
            LcmStyleSheet styleSheet = new LcmStyleSheet();

            styleSheet.Init(Cache, Cache.LangProject.Hvo, LangProjectTags.kflidStyles);

            using (Form form = new Form())
                using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache))
                {
                    footnoteView.StyleSheet = styleSheet;
                    footnoteView.Dock       = DockStyle.Fill;
                    footnoteView.Name       = "footnoteView";
                    footnoteView.Visible    = true;
                    form.Controls.Add(footnoteView);
                    form.Show();

                    try
                    {
                        // Select the footnote marker and some characters of the footnote paragraph
                        footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
                        SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
                        selHelper.IchAnchor = 0;
                        selHelper.IchEnd    = 5;
                        SelLevInfo[] selLevInfo = new SelLevInfo[3];
                        Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
                        Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
                        selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
                        selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
                                                StTxtParaTags.kflidContents);
                        selHelper.SetSelection(true);

                        // Now the real test:
                        IVwSelection sel = footnoteView.RootBox.Selection;
                        ITsString    tss;
                        sel.GetSelectionString(out tss, string.Empty);
                        Assert.AreEqual("a ", tss.Text.Substring(0, 2));

                        // make sure the marker and the space are read-only and the paragraph not.
                        ITsTextProps[]     vttp;
                        IVwPropertyStore[] vvps;
                        int cttp;
                        SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
                        Assert.IsTrue(cttp >= 3);
                        Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
                                       "Footnote marker is not read-only");
                        Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
                                       "Space after marker is not read-only");
                        Assert.IsTrue(SelectionHelper.IsEditable(vttp[2], vvps[2]),
                                      "Footnote text is read-only");
                        Assert.IsTrue(SelectionHelper.IsEditable(vttp[3], vvps[3]),
                                      "Footnote text is read-only");
                    }
                    finally
                    {
                        form.Close();
                    }
                }
        }
Esempio n. 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Set up Undo action and initialize the stylesheet
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void TestSetup()
        {
            base.TestSetup();

            m_styleSheet = new LcmStyleSheet();
            // Force load of styles
            IScripture scr = Cache.LangProject.TranslatedScriptureOA;

            Assert.IsTrue(Cache.LangProject.StylesOC.Count > 0);
            m_styleSheet.Init(Cache, Cache.LangProject.Hvo, LangProjectTags.kflidStyles);
        }
Esempio n. 8
0
        public void SpaceAfterFootnoteMarker()
        {
            IScrBook     book     = m_scr.ScriptureBooksOS[0];
            IScrFootnote footnote = AddFootnote(book, (IStTxtPara)book.TitleOA.ParagraphsOS[0], 0, "This is a footnote");

            footnote.FootnoteMarker = TsStringUtils.MakeString("a", Cache.WritingSystemFactory.GetWsFromStr("en"));
            // Prepare the test by creating a footnote view
            LcmStyleSheet styleSheet = new LcmStyleSheet();

            styleSheet.Init(Cache, Cache.LangProject.Hvo, LangProjectTags.kflidStyles);

            using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache))
            {
                footnoteView.StyleSheet = styleSheet;
                footnoteView.Visible    = false;

                // We don't actually want to show it, but we need to force the view to create the root
                // box and lay it out so that various test stuff can happen properly.
                footnoteView.MakeRoot();
                footnoteView.CallLayout();

                // Select the footnote marker and some characters of the footnote paragraph
                footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
                SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
                selHelper.IchAnchor = 0;
                selHelper.IchEnd    = 5;
                SelLevInfo[] selLevInfo = new SelLevInfo[3];
                Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
                Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
                selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
                selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
                                        StTxtParaTags.kflidContents);
                selHelper.SetSelection(true);

                // Now the real test:
                IVwSelection sel = footnoteView.RootBox.Selection;
                ITsString    tss;
                sel.GetSelectionString(out tss, string.Empty);
                Assert.AreEqual("a ", tss.Text.Substring(0, 2));

                // make sure the marker and the space are read-only (maybe have to select each run
                // separately to make this test truly correct)
                ITsTextProps[]     vttp;
                IVwPropertyStore[] vvps;
                int cttp;
                SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
                Assert.IsTrue(cttp >= 2);
                Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
                               "Footnote marker is not read-only");
                Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
                               "Space after marker is not read-only");
            }
        }
Esempio n. 9
0
        public void LoadParatextMappings_MissingEncodingFile()
        {
            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ParatextScrProj = "NEC";

            Unpacker.UnPackMissingFileParatextTestProjects();

            ParatextHelper.LoadProjectMappings(importSettings);
            Assert.That(importSettings.ParatextScrProj, Is.Null);
        }
Esempio n. 10
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Create a new basic view
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public override void TestSetup()
        {
            base.TestSetup();

            var styleSheet = new LcmStyleSheet();

            styleSheet.Init(Cache, Cache.LangProject.Hvo,
                            LangProjectTags.kflidStyles);

            Debug.Assert(m_basicView == null, "m_basicView is not null.");

            m_basicView = new DummyBasicView {
                Cache = Cache, Visible = false, StyleSheet = styleSheet
            };
        }
Esempio n. 11
0
        public void NoStyleSelected_AllTabsHidden(string selectedStyle, int visibleTabs)
        {
            var stylesheet = new LcmStyleSheet();

            stylesheet.Init(Cache, Cache.LangProject.Hvo, LangProjectTags.kflidStyles);

            var sut = new DummyFwStylesDlg(null, Cache, stylesheet, false, false, "Normal", 0, MsrSysType.Cm,
                                           selectedStyle, string.Empty, 0, null, null);

            Assert.That(sut.TabControl.TabCount, Is.EqualTo(visibleTabs));
            Assert.That(sut.TabControl.TabPages, Contains.Item(sut.TbGeneral), "The General tab should always be visible");
            if (visibleTabs > 1)
            {
                Assert.That(sut.TabControl.TabPages, Contains.Item(sut.TbFont), "The Font tab should be visible for both character and paragraph styles");
            }
        }
Esempio n. 12
0
        public override void TestSetup()
        {
            base.TestSetup();

            var styleSheet = new LcmStyleSheet();

            styleSheet.Init(Cache, Cache.LangProject.Hvo, LangProjectTags.kflidStyles);

            Debug.Assert(m_basicView == null, "m_basicView is not null.");
            //if (m_basicView != null)
            //	m_basicView.Dispose();
            m_basicView            = CreateDummyBasicView();
            m_basicView.Cache      = Cache;
            m_basicView.Visible    = false;
            m_basicView.StyleSheet = styleSheet;
        }
Esempio n. 13
0
        private static IVwStylesheet GetStyleSheet(LcmCache cache, PropertyTable propertyTable)
        {
            IVwStylesheet vss = StyleSheetFromPropertyTable(propertyTable);

            if (vss != null)
            {
                return(vss);
            }
            // Get a style sheet for the Language Explorer, and store it in the
            // (new) mediator.
            LcmStyleSheet styleSheet = new LcmStyleSheet();

            styleSheet.Init(cache, cache.LanguageProject.Hvo, LangProjectTags.kflidStyles);
            propertyTable.SetProperty("LcmStyleSheet", styleSheet, true);
            propertyTable.SetPropertyPersistence("LcmStyleSheet", false);
            return(styleSheet);
        }
Esempio n. 14
0
        protected override void CreateTestData()
        {
            m_lp = Cache.LanguageProject;

            AddTestStyle("Normal", ContextValues.Internal, StructureValues.Undefined,
                         FunctionValues.Prose, false, m_lp.StylesOC);
            AddTestStyle("Paragraph", ContextValues.Text, StructureValues.Body,
                         FunctionValues.Prose, false, m_lp.StylesOC);
            AddTestStyle("Section Head", ContextValues.Text, StructureValues.Heading,
                         FunctionValues.Prose, false, m_lp.StylesOC);
            AddTestStyle("Verse Number", ContextValues.Text, StructureValues.Body,
                         FunctionValues.Verse, true, m_lp.StylesOC);
            AddTestStyle("Title Main", ContextValues.Title, StructureValues.Body,
                         FunctionValues.Prose, false, m_lp.StylesOC);
            AddTestStyle("Note General Paragraph", ContextValues.Note, StructureValues.Undefined,
                         FunctionValues.Prose, false, m_lp.StylesOC);
            AddTestStyle("Note Marker", ContextValues.Internal, StructureValues.Undefined,
                         FunctionValues.Prose, true, m_lp.StylesOC);
            AddTestStyle(kStyleName, ContextValues.Text, StructureValues.Body,
                         FunctionValues.Prose, true, 2, m_lp.StylesOC);

            // Setup the stylesheet.
            var captionStyle = AddTestStyle("Caption", ContextValues.Internal,
                                            StructureValues.Body, FunctionValues.Prose, false,
                                            m_lp.StylesOC);

            m_styleSheet = new LcmStyleSheet();
            m_styleSheet.Init(Cache, m_lp.Hvo,
                              LangProjectTags.kflidStyles);

            Debug.Assert(m_stylesComboBox == null, "m_stylesComboBox is not null.");
            //if (m_stylesComboBox != null)
            //	m_stylesComboBox.Dispose();
            m_stylesComboBox  = new ComboBox();
            m_styleListHelper = new StyleComboListHelper(m_stylesComboBox);

            // Set the options to display all of the styles
            m_styleListHelper.MaxStyleLevel = int.MaxValue;
        }
Esempio n. 15
0
        public void FootnoteTranslationTest()
        {
            // get an existing footnote
            IScrBook     book     = m_scr.ScriptureBooksOS[1];     // book of Exodus
            IScrFootnote footnote = AddFootnote(book, (IStTxtPara)book.TitleOA.ParagraphsOS[0], 0, "This is a footnote");
            IStTxtPara   para     = (IStTxtPara)footnote.ParagraphsOS[0];

            // add a translation to the footnote
            ICmTranslation translation = para.GetOrCreateBT();
            int            analWs      = Cache.DefaultAnalWs;

            translation.Translation.set_String(analWs, TsStringUtils.MakeString("abcde", analWs));

            LcmStyleSheet styleSheet = new LcmStyleSheet();

            styleSheet.Init(Cache, Cache.LangProject.Hvo, LangProjectTags.kflidStyles);

            // Prepare the test by creating a footnote view
            using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache, true))
            {
                footnoteView.StyleSheet = styleSheet;
                footnoteView.Visible    = false;

                // We don't actually want to show it, but we need to force the view to create the root
                // box and lay it out so that various test stuff can happen properly.
                footnoteView.MakeRoot();
                footnoteView.CallLayout();

                // Select the footnote marker and some characters of the footnote paragraph
                footnoteView.RootBox.MakeSimpleSel(true, true, false, true);

                // Now the real test:
                IVwSelection sel = footnoteView.RootBox.Selection.GrowToWord();
                ITsString    tss;
                sel.GetSelectionString(out tss, string.Empty);
                Assert.AreEqual("abcde", tss.Text);
            }
        }
Esempio n. 16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initialize the importer
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void TestSetup()
        {
            base.TestSetup();

            m_styleSheet = new LcmStyleSheet();
            m_styleSheet.Init(Cache, Cache.LangProject.Hvo, LangProjectTags.kflidStyles);
            InitWsInfo();

            DummyParatextImporter.s_translatorNoteDefn = Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().TranslatorAnnotationDefn;
            DummyParatextImporter.s_consultantNoteDefn = Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().ConsultantAnnotationDefn;

            m_titus                      = new BCVRef(56001001);
            m_settings                   = m_scr.FindOrCreateDefaultImportSettings(TypeOfImport.Other, m_styleSheet, FwDirectoryFinder.FlexStylesPath);
            m_settings.StartRef          = m_titus;
            m_settings.EndRef            = m_titus;
            m_settings.ImportTranslation = true;
            InitializeImportSettings();

            m_actionHandler.EndUndoTask();             // Let the importer handle the undo/redo
            m_importer = new DummyParatextImporter(m_settings, this, m_styleSheet);
            m_importer.Initialize();
            m_importer.UndoInfo.StartImportingFiles();
        }