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."); }
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; } } }
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); }
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); } }
/// ------------------------------------------------------------------------------------ /// <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; }
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(); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor with ContextValues and MarkerDomain as a parameters. /// </summary> /// <param name="mapping">The Scr marker mapping.</param> /// <param name="ws">character or paragraph writing system</param> /// <param name="styleSheet">The style sheet</param> /// ------------------------------------------------------------------------------------ public ImportStyleProxy(ImportMappingInfo mapping, int ws, LcmStyleSheet styleSheet) : this(mapping.StyleName, mapping.IsInline ? StyleType.kstCharacter : StyleType.kstParagraph, ws, ContextValues.General, mapping.Domain, styleSheet) { Excluded = mapping.IsExcluded; MappingTarget = mapping.MappingTarget; m_annotationType = mapping.NoteType; }
/// <summary> /// Initializes a new instance of the <see cref="ParatextImportManager"/> class. /// </summary> /// <param name="mainWnd">The main window initiating the import</param> /// <param name="cache"></param> /// <param name="importSettings"></param> /// <param name="styleSheet">The stylesheet.</param> /// <param name="app">The app.</param> internal ParatextImportManager(Form mainWnd, LcmCache cache, IScrImportSet importSettings, LcmStyleSheet styleSheet, IApp app) { m_mainWnd = mainWnd; // Null for tests. Cache = cache; m_importSettings = importSettings; m_helpTopicProvider = app as IHelpTopicProvider; m_app = app; StyleSheet = styleSheet; }
/// <inheritdoc/> public DummyFwStylesDlg(IVwRootSite rootSite, LcmCache cache, LcmStyleSheet styleSheet, bool defaultRightToLeft, bool showBiDiLabels, string normalStyleName, int customUserLevel, MsrSysType userMeasurementType, string paraStyleName, string charStyleName, int hvoRootObject, IApp app, IHelpTopicProvider helpTopicProvider) : base(rootSite, cache, styleSheet, defaultRightToLeft, showBiDiLabels, normalStyleName, customUserLevel, userMeasurementType, paraStyleName, charStyleName, hvoRootObject, app, helpTopicProvider) { }
/// ------------------------------------------------------------------------------------ /// <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); }
/// <summary> /// /// </summary> public override void TestTearDown() { m_lp = null; m_styleSheet = null; m_stylesComboBox.Dispose(); m_stylesComboBox = null; m_styleListHelper.Dispose(); m_styleListHelper = null; base.TestTearDown(); }
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"); } }
public override void TestTearDown() { if (m_actionHandler.CurrentDepth > 0) { m_importer.UndoInfo.DoneImportingFiles(true); } m_importer.Dispose(); m_importer = null; m_styleSheet = null; m_settings = null; // Restart an undo task so we don't crash :) m_actionHandler.BeginUndoTask("bla", "bla"); base.TestTearDown(); }
/// ----------------------------------------------------------------------------------- /// <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 }; }
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); }
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; }
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"); } }
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); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor with ContextValues and MarkerDomain as a parameters. /// </summary> /// <param name="sStyleName">Name of the style.</param> /// <param name="styleType">kstCharacter or kstParagraph</param> /// <param name="ws">character or paragraph writing system</param> /// <param name="context">Context that will be used if this is a new style (otherwise existing /// context in DB will be used), see ContextValues for possible types</param> /// <param name="domain">The marker domain to use</param> /// <param name="styleSheet">The style sheet</param> /// ------------------------------------------------------------------------------------ public ImportStyleProxy(string sStyleName, StyleType styleType, int ws, ContextValues context, MarkerDomain domain, LcmStyleSheet styleSheet) { m_LcmStyleSheet = styleSheet; m_domain = domain; Debug.Assert(m_LcmStyleSheet != null); m_ttpFormattingProps = null; m_fIsScriptureStyle = true; //default m_sEndMarker = null; //default if (context == ContextValues.EndMarker) { // this proxy represents an end marker - not a style; set bogus info sStyleName = "End"; //name does not matter styleType = StyleType.kstCharacter; } else if (sStyleName != null) { // Determine whether style exists in the StyleSheet Debug.Assert(ws != 0); m_style = m_LcmStyleSheet.FindStyle(sStyleName); if (m_style != null) { // If this is an existing style, the actual type, context, structure, and // function always override the requested values. styleType = m_style.Type; context = (ContextValues)m_style.Context; m_structure = (StructureValues)m_style.Structure; m_function = (FunctionValues)m_style.Function; } } m_sStyleName = sStyleName; m_StyleType = styleType; m_ws = ws; m_Context = context; // //force StartOfFootnote marker to be processed as a para style proxy having para props // if (context == StyleRole.StartOfFootnote) // m_StyleType = StyleType.kstParagraph; //set the text property vars for this proxy SetTextProps(); }
public void AddHyperlink() { ITsStrBldr strBldr = TsStringUtils.MakeStrBldr(); LcmStyleSheet mockStylesheet = MockRepository.GenerateStub <LcmStyleSheet>(); IStStyle mockHyperlinkStyle = MockRepository.GenerateStub <IStStyle>(); mockHyperlinkStyle.Name = StyleServices.Hyperlink; mockHyperlinkStyle.Stub(x => x.InUse).Return(true); mockStylesheet.Stub(x => x.FindStyle(StyleServices.Hyperlink)).Return(mockHyperlinkStyle); Assert.IsTrue(FwEditingHelper.AddHyperlink(strBldr, Cache.DefaultAnalWs, "Click Here", "www.google.com", mockStylesheet)); Assert.AreEqual(1, strBldr.RunCount); Assert.AreEqual("Click Here", strBldr.get_RunText(0)); ITsTextProps props = strBldr.get_Properties(0); LcmTestHelper.VerifyHyperlinkPropsAreCorrect(props, Cache.DefaultAnalWs, "www.google.com"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the specified font info. /// </summary> /// <param name="fontInfo">The font info.</param> /// <param name="fAllowSubscript"><c>true</c> to allow super/subscripts, <c>false</c> /// to disable the controls (used when called from Borders and Bullets tab)</param> /// <param name="ws">The default writing system (usually UI ws)</param> /// <param name="wsf">The writing system factory</param> /// <param name="styleSheet">The style sheet.</param> /// <param name="fAlwaysDisableFontFeatures"><c>true</c> to disable the Font Features /// button even when a Graphite font is selected.</param> /// ------------------------------------------------------------------------------------ void IFontDialog.Initialize(FontInfo fontInfo, bool fAllowSubscript, int ws, ILgWritingSystemFactory wsf, LcmStyleSheet styleSheet, bool fAlwaysDisableFontFeatures) { m_DefaultWs = ws; m_preview.WritingSystemFactory = wsf; m_preview.WritingSystemCode = ws; m_preview.StyleSheet = styleSheet; m_tbFontName.Text = fontInfo.UIFontName(); FontSize = fontInfo.m_fontSize.Value / 1000; m_tbFontSize.Text = FontSize.ToString(CultureInfo.InvariantCulture); m_FontAttributes.UpdateForStyle(fontInfo); m_FontAttributes.AllowSuperSubScript = fAllowSubscript; m_FontAttributes.AlwaysDisableFontFeatures = fAlwaysDisableFontFeatures; UpdatePreview(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Appends the given text as a hyperlink to the given URL. /// </summary> /// <param name="strBldr">The string builder.</param> /// <param name="ws">The HVO of the writing system to use for the added text.</param> /// <param name="sLinkText">The text which should appear as the hyperlink text</param> /// <param name="sUrl">The URL that is the target of the hyperlink.</param> /// <param name="stylesheet">The stylesheet.</param> /// <returns><c>true</c> if the hyperlink was successfully inserted; <c>false</c> /// otherwise (indicating that the hyperlink style could not be found in the given /// stylesheet). In either case, the link text will be appended to the string builder. /// </returns> /// ------------------------------------------------------------------------------------ public static bool AddHyperlink(ITsStrBldr strBldr, int ws, string sLinkText, string sUrl, LcmStyleSheet stylesheet) { var hyperlinkStyle = stylesheet.FindStyle(StyleServices.Hyperlink); if (hyperlinkStyle == null) { return(false); } if (stylesheet != null && stylesheet.Cache != null && stylesheet.Cache.ProjectId != null) { sUrl = FwLinkArgs.FixSilfwUrlForCurrentProject(sUrl, stylesheet.Cache.ProjectId.Name); } int ichStart = strBldr.Length; strBldr.Replace(ichStart, ichStart, sLinkText, StyleUtils.CharStyleTextProps(null, ws)); StringServices.MarkTextInBldrAsHyperlink(strBldr, ichStart, strBldr.Length, sUrl, hyperlinkStyle); return(true); }
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; }
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); } }
/// ------------------------------------------------------------------------------------ /// <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(); }
public void SetupDialog(HomographConfiguration hc, LcmCache cache, LcmStyleSheet stylesheet, IApp app, IHelpTopicProvider helpTopicProvider) { SetHelpTopic("khtpConfigureHeadwordNumbers"); // Default help topic ID m_helpProvider = new HelpProvider(); m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic); m_helpProvider.SetShowHelp(this, true); m_homographConfiguration = hc; m_cache = cache; m_stylesheet = stylesheet; m_app = app; m_helpTopicProvider = helpTopicProvider; if (m_helpTopicProvider != null) { m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile; SetHelpButtonEnabled(); } if (hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main)) { m_radioHide.Checked = false; m_radioBefore.Checked = hc.HomographNumberBefore; m_radioAfter.Checked = !hc.HomographNumberBefore; m_chkShowSenseNumInReversal.Checked = hc.ShowSenseNumberReversal; } else { m_radioHide.Checked = true; m_radioBefore.Checked = false; m_radioAfter.Checked = false; m_chkShowSenseNumInReversal.Checked = false; } m_chkShowHomographNumInReversal.Checked = hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef); EnableControls(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the style names to the combo box or list box from the specified stylesheet. /// </summary> /// <param name="styleSheet">Stylesheet from which styles are read.</param> /// <param name="pseudoStyles">Array of strings representing pseudo-styles that can be /// displayed for the purpose of mapping markers to data properties</param> /// ------------------------------------------------------------------------------------ public void AddStyles(LcmStyleSheet styleSheet, string[] pseudoStyles) { Debug.Assert(styleSheet != null); BuildStyleItemList(styleSheet.CStyles, styleSheet.Styles, pseudoStyles); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the style names to the combo box or list box from the specified stylesheet. /// </summary> /// <param name="styleSheet">Stylesheet from which styles are read.</param> /// ------------------------------------------------------------------------------------ public void AddStyles(LcmStyleSheet styleSheet) { AddStyles(styleSheet, null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor with ContextValues as a parameter. /// </summary> /// <param name="sStyleName">Name of the style.</param> /// <param name="styleType">kstCharacter or kstParagraph</param> /// <param name="ws">character or paragraph writing system</param> /// <param name="context">Context that will be used if this is a new style (otherwise existing /// context in DB will be used), see ContextValues for possible types</param> /// <param name="styleSheet">The style sheet</param> /// ------------------------------------------------------------------------------------ public ImportStyleProxy(string sStyleName, StyleType styleType, int ws, ContextValues context, LcmStyleSheet styleSheet) : this(sStyleName, styleType, ws, context, MarkerDomain.Default, styleSheet) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public override void TestTearDown() { m_styleSheet = null; base.TestTearDown(); }