/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_style = new StStyle(); Cache.LangProject.StylesOC.Add(m_style); m_style.Name = "Section Head Major"; m_style.UserLevel = -1; }
public void UserDefinedCharacterStyle_ExplicitFontName() { // Create a style with an unspecified font name. IStStyle charStyle = new StStyle(); Cache.LangProject.StylesOC.Add(charStyle); charStyle.Context = ContextValues.Text; charStyle.Function = FunctionValues.Prose; charStyle.Structure = StructureValues.Body; charStyle.Type = StyleType.kstCharacter; StyleInfo basedOn = new StyleInfo(charStyle); // Create a user-defined character style inherited from the previously-created character // style, but this style has a font name specified. StyleInfo charStyleInfo = new StyleInfo("New Char Style", basedOn, StyleType.kstCharacter, Cache); FontInfo charFontInfo = charStyleInfo.FontInfoForWs(Cache.DefaultVernWs); m_fontTab.UpdateForStyle(charStyleInfo); // Select a font name for the style (which will call the event handler // m_cboFontNames_SelectedIndexChanged). FwInheritablePropComboBox cboFontNames = ReflectionHelper.GetField(m_fontTab, "m_cboFontNames") as FwInheritablePropComboBox; Assert.IsNotNull(cboFontNames); cboFontNames.AdjustedSelectedIndex = 2; // Make sure we successfully set the font for this user-defined character style. Assert.IsTrue(charStyleInfo.FontInfoForWs(-1).m_fontName.IsExplicit); Assert.AreEqual("<default pub font>", charStyleInfo.FontInfoForWs(-1).m_fontName.Value, "The font should have been set to the default publication font."); cboFontNames.AdjustedSelectedIndex = 3; // Make sure we successfully set the font for this user-defined character style. Assert.IsTrue(charStyleInfo.FontInfoForWs(-1).m_fontName.IsExplicit); Assert.AreEqual("<default sans serif>", charStyleInfo.FontInfoForWs(-1).m_fontName.Value, "The font should have been set to the default heading font (i.e., sans-serif)."); }
public void SetGetSingleUnicode() { CheckDisposed(); StStyle st = new StStyle(); Cache.LangProject.StylesOC.Add(st); string s = "NewName" + m_rand.Next().ToString(); st.Name = s; Assert.AreEqual(s, st.Name); }
public void StyleCollectionWorksWithUpperAscii() { string styleName = "\u00e1bc"; StStyle style = new StStyle(); Cache.LangProject.StylesOC.Add(style); style.Name = styleName; FwStyleSheet.StyleInfoCollection styleCollection = new FwStyleSheet.StyleInfoCollection(); styleCollection.Add(new BaseStyleInfo(style)); Assert.IsTrue(styleCollection.Contains(styleName.Normalize(NormalizationForm.FormC))); Assert.IsTrue(styleCollection.Contains(styleName.Normalize(NormalizationForm.FormD))); Assert.IsTrue(styleCollection.Contains(styleName.Normalize(NormalizationForm.FormKC))); Assert.IsTrue(styleCollection.Contains(styleName.Normalize(NormalizationForm.FormKD))); }
public void SaveToDB_CopyOfStyleBasedOnNormal() { StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.LanguageWritingSystemFactoryAccessor); IStStyle normalStyle = new StStyle(); Cache.LangProject.StylesOC.Add(normalStyle); normalStyle.Name = "Normal"; normalStyle.Context = ContextValues.Internal; normalStyle.Function = FunctionValues.Prose; normalStyle.Structure = StructureValues.Undefined; StyleInfo normal = new StyleInfo(normalStyle); styleTable.Add("Normal", normal); IStStyle realStyle = new StStyle(); Cache.LangProject.StylesOC.Add(realStyle); realStyle.Name = "Paragraph"; realStyle.Context = ContextValues.Text; realStyle.Function = FunctionValues.Prose; realStyle.Structure = StructureValues.Body; realStyle.BasedOnRA = normalStyle; StyleInfo styleToCopyFrom = new StyleInfo(realStyle); styleTable.Add("Paragraph", styleToCopyFrom); StyleInfo testInfo = new StyleInfo(styleToCopyFrom, "Copy of Paragraph"); styleTable.Add("Copy of Paragraph", testInfo); styleTable.ConnectStyles(); // simulate a save to the DB for the test style. IStStyle style = new StStyle(); Cache.LangProject.StylesOC.Add(style); testInfo.SaveToDB(style, false); Assert.AreEqual(ContextValues.Text, testInfo.Context); Assert.AreEqual(StructureValues.Body, testInfo.Structure); Assert.AreEqual(FunctionValues.Prose, testInfo.Function); Assert.AreEqual(ContextValues.Text, style.Context); Assert.AreEqual(StructureValues.Body, style.Structure); Assert.AreEqual(FunctionValues.Prose, style.Function); }
public void SaveToDB_NewInfo() { IStStyle realStyle = new StStyle(); Cache.LangProject.StylesOC.Add(realStyle); realStyle.Context = ContextValues.Intro; realStyle.Function = FunctionValues.Table; realStyle.Structure = StructureValues.Heading; StyleInfo basedOn = new StyleInfo(realStyle); StyleInfo testInfo = new StyleInfo("New Style", basedOn, StyleType.kstParagraph, Cache); // simulate a save to the DB for the test style. IStStyle style = new StStyle(); Cache.LangProject.StylesOC.Add(style); testInfo.SaveToDB(style, false); Assert.AreEqual(ContextValues.Intro, testInfo.Context); Assert.AreEqual(StructureValues.Heading, testInfo.Structure); Assert.AreEqual(FunctionValues.Table, testInfo.Function); Assert.AreEqual(ContextValues.Intro, style.Context); Assert.AreEqual(StructureValues.Heading, style.Structure); Assert.AreEqual(FunctionValues.Table, style.Function); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Obtain a style object from a style name. /// </summary> /// <param name="styleName">Name of style to find</param> /// ------------------------------------------------------------------------------------ public IStStyle FindStyle(string styleName) { foreach (int hvo in StylesOC.HvoArray) { // We assume the HVO of the style is valid if we find it in the HVO array IStStyle style = new StStyle(m_cache, hvo, false, false) as IStStyle; if (style.Name == styleName) return style; } return null; }
public void SaveToDB_NewInfoAndBasedOnNewInfo() { IStStyle realStyle = new StStyle(); Cache.LangProject.StylesOC.Add(realStyle); realStyle.Context = ContextValues.Intro; realStyle.Function = FunctionValues.Table; realStyle.Structure = StructureValues.Heading; StyleInfo basedOn = new StyleInfo(realStyle); StyleInfo testInfo1 = new StyleInfo("New Style 1", basedOn, StyleType.kstParagraph, Cache); StyleInfo testInfo2 = new StyleInfo("New Style 2", testInfo1, StyleType.kstParagraph, Cache); // simulate a save to the DB for the test styles. Save the second one first for // a better test. IStStyle style2 = new StStyle(); Cache.LangProject.StylesOC.Add(style2); testInfo2.SaveToDB(style2, false); IStStyle style = new StStyle(); Cache.LangProject.StylesOC.Add(style); testInfo1.SaveToDB(style, false); Assert.AreEqual(ContextValues.Intro, testInfo1.Context); Assert.AreEqual(StructureValues.Heading, testInfo1.Structure); Assert.AreEqual(FunctionValues.Table, testInfo1.Function); Assert.AreEqual(ContextValues.Intro, style.Context); Assert.AreEqual(StructureValues.Heading, style.Structure); Assert.AreEqual(FunctionValues.Table, style.Function); Assert.AreEqual(ContextValues.Intro, testInfo2.Context); Assert.AreEqual(StructureValues.Heading, testInfo2.Structure); Assert.AreEqual(FunctionValues.Table, testInfo2.Function); Assert.AreEqual(ContextValues.Intro, style2.Context); Assert.AreEqual(StructureValues.Heading, style2.Structure); Assert.AreEqual(FunctionValues.Table, style2.Function); }
public void AddDeleteStyle() { CheckDisposed(); ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create(); ITsTextProps ttpFormattingProps = tsPropsBldr.GetTextProps(); // default properties int nStylesOrig = m_styleSheet.CStyles; // get an hvo for the new style int hvoStyle = m_styleSheet.MakeNewStyle(); StStyle style = new StStyle(m_styleSheet.Cache, hvoStyle); // PutStyle() adds the style to the stylesheet m_styleSheet.PutStyle("MyNewStyle", "bla", hvoStyle, 0, hvoStyle, 0, false, false, ttpFormattingProps); Assert.AreEqual(nStylesOrig + 1, m_styleSheet.CStyles); Assert.AreEqual(ttpFormattingProps, m_styleSheet.GetStyleRgch(0, "MyNewStyle"), "Should get correct format props for the style added"); // Make style be based on section head and check context IStStyle baseOnStyle = m_scr.FindStyle(ScrStyleNames.SectionHead); m_styleSheet.PutStyle("MyNewStyle", "bla", hvoStyle, baseOnStyle.Hvo, hvoStyle, 0, false, false, ttpFormattingProps); Assert.AreEqual(baseOnStyle.Context, style.Context); // Now delete the new style m_styleSheet.Delete(hvoStyle); // Verfiy the deletion Assert.AreEqual(nStylesOrig, m_styleSheet.CStyles); Assert.IsNull(m_styleSheet.GetStyleRgch(0, "MyNewStyle"), "Should get null because style is not there"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Do nothing /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_styleOrig = new StStyle(); m_scr.StylesOC.Add(m_styleOrig); m_styleOrig.Name = "Cool style"; m_styleOrig.Context = ContextValues.Intro; m_styleOrig.IsBuiltIn = true; m_styleOrig.InUse = true; m_styleReplace = new StStyle(); m_scr.StylesOC.Add(m_styleReplace); m_styleReplace.Name = "Cooler style"; m_styleReplace.IsBuiltIn = true; }
//[Ignore("Has problems with new restore database approach")] public void Transactions() { CheckDisposed(); if (!m_fdoCache.DatabaseAccessor.IsTransactionOpen()) m_fdoCache.DatabaseAccessor.BeginTrans(); StStyle newStyle = new StStyle(); m_fdoCache.LangProject.StylesOC.Add(newStyle); int newStyleHvo = newStyle.Hvo; m_fdoCache.DatabaseAccessor.RollbackTrans(); // A simple rollback will not clear the object from the cache, // so do it here. m_fdoCache.VwCacheDaAccessor.ClearInfoAbout(newStyleHvo, VwClearInfoAction.kciaRemoveAllObjectInfo); if (newStyle.IsValidObject()) { // Should not get here, as the create call should throw the exception. // Just in case, however, delete the new object. newStyle.DeleteUnderlyingObject(); Assert.Fail("Object is still valid."); } }
public void BeginAndEndUndoTask() { CheckDisposed(); ShowForm(); // we need a selection m_basicView.RootBox.MakeSimpleSel(true, true, false, true); // this should begin an outer undo task, so we will have only one undoable task! using(new UndoTaskHelper(m_basicView, "kstidUndoStyleChanges")) { m_fdoCache.BeginUndoTask("", ""); StStyle style = new StStyle(); m_fdoCache.LangProject.StylesOC.Add(style); m_fdoCache.EndUndoTask(); m_fdoCache.BeginUndoTask("", ""); style = new StStyle(); m_fdoCache.LangProject.StylesOC.Add(style); m_fdoCache.EndUndoTask(); } int nUndoTasks = 0; while(m_fdoCache.Undo()) { nUndoTasks++; } Assert.AreEqual(1, nUndoTasks); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. } // Dispose unmanaged resources here, whether disposing is true or false. m_style = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------- /// <summary> /// If existing style is NOT a factory style, we're about to "clobber" a user style. If /// the context, structure, and function don't match (and maybe even if they do), this /// could be pretty bad. Store info necessary to rename their style and change all the /// uses of it. /// </summary> /// <param name="style">Style to check.</param> /// <param name="type">Style type we want</param> /// <param name="context">The context we want</param> /// <param name="structure">The structure we want</param> /// <param name="function">The function we want</param> /// <returns>Either the passed in style, or a new style if the passed in one cannot be /// redefined as requested.</returns> /// ------------------------------------------------------------------------------------- public IStStyle EnsureCompatibleFactoryStyle(IStStyle style, StyleType type, ContextValues context, StructureValues structure, FunctionValues function) { if (style.IsBuiltIn && (style.Context != context || style.Function != function) && IsValidInternalStyleContext(style, context)) { // For now, at least, this method only deals with context changes. Theoretically, // we could in the future have a function, type, or structure change that would // require some special action. ChangeFactoryStyleToInternal(style, context); if (style.Type != type) style.Type = type; // Structure and function are probably meaningless for internal styles, but just // to be sure... if (style.Structure != structure) style.Structure = structure; if (style.Function != function) style.Function = function; return style; } if (style.Type != type || !CompatibleContext(style.Context, context) || style.Structure != structure || !CompatibleFunction(style.Function, function)) { if (style.IsBuiltIn) ReportInvalidInstallation(String.Format( FrameworkStrings.ksCannotRedefineFactoryStyle, style.Name, ResourceFileName)); // If style is in use, add it to the list so we can search through all // paragraphs and replace it with a new renamed style (and rename the style // itself, too); if (StyleIsInUse(style)) { // ENHANCE: Prompt user to pick a different name to rename to // TODO: Check for collision - make sure we get a unique name string sNewName = style.Name + ResourceHelper.GetResourceString("kstidUserStyleSuffix"); m_replacedStyles.Add(new StyleReplacement(style.Name, sNewName)); style.Name = sNewName; } IStStyle newFactoryStyle = new StStyle(); m_databaseStyles.Add(newFactoryStyle); return newFactoryStyle; } if (style.Context != context) style.Context = context; if (style.Function != function) style.Function = function; return style; }
public override void Exit() { CheckDisposed(); m_styleOrig = null; m_styleReplace = null; base.Exit(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new style and add it to the Language Project stylesheet. /// </summary> /// <param name="name">style name</param> /// <param name="context">style context</param> /// <param name="structure">style structure</param> /// <param name="function">style function</param> /// <param name="isCharStyle">true if character style, otherwise false</param> /// <param name="userLevel">The user level.</param> /// <param name="styleCollection">The style collection.</param> /// <returns>The style</returns> /// ------------------------------------------------------------------------------------ public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure, FunctionValues function, bool isCharStyle, int userLevel, FdoOwningCollection<IStStyle> styleCollection) { CheckDisposed(); ITsPropsBldr bldr = TsPropsBldrClass.Create(); StStyle style = new StStyle(); styleCollection.Add(style); style.Name = name; style.Context = context; style.Structure = structure; style.Function = function; style.Rules = bldr.GetTextProps(); style.Type = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph); style.UserLevel = userLevel; return style; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Click event of the m_btnOk control. /// </summary> /// ------------------------------------------------------------------------------------ private void m_btnOk_Click(object sender, EventArgs e) { if (IsRootSiteDisposed()) { MessageBox.Show(FwCoreDlgs.kstidChangesAreLost, FwCoreDlgs.kstidWarning); DialogResult = DialogResult.Cancel; return; } using (new WaitCursor(this)) { // We can't use using() here because we might have to create a new undo task below. CreateUndoTaskHelper(); try { // This makes sure the style sheet gets reinitialized after an Undo command. if (m_cache.ActionHandlerAccessor != null) { m_cache.ActionHandlerAccessor.AddAction( new UndoStyleChangesAction(m_app, m_cache, true)); } // Save any edits from the dialog to the selected style if (m_styleListHelper.SelectedStyle != null) { StyleInfo styleInfo = (StyleInfo)m_styleListHelper.SelectedStyle.StyleInfo; UpdateChanges(styleInfo); } // Check to make sure new styles are not going to result in duplicates // in the database m_styleSheet.CheckForDuplicates(m_styleTable); // Save any changed styles to the database foreach (StyleInfo style in m_styleTable.Values) { if (style.Dirty && style.IsValid) { // If there is already a real style, then the style has changed if (style.RealStyle != null) { style.SaveToDB(style.RealStyle, true); m_changeType |= StyleChangeType.DefChanged; } else { // otherwise, the style does not exist - it has been added // REVIEW: Don't we need to make sure some other user hasn't already // added this style before saving it in the DB? StStyle newStyle = new StStyle(m_cache, m_styleSheet.MakeNewStyle()); style.SaveToDB(newStyle, false); m_changeType |= StyleChangeType.Added; } } } // Save the real styles for based-on and following style. Do this last so // all of the real styles for added styles will have been created. foreach (StyleInfo style in m_styleTable.Values) { if (style.Dirty && style.IsValid) style.SaveBasedOnAndFollowingToDB(); style.Dirty = false; } DeleteAndRenameStylesInDB(); // Has the user modified any of the styles? if (m_changeType > 0) { if ((m_changeType & StyleChangeType.RenOrDel) > 0) { // Styles were renamed or deleted. // Because this might involve quite a bit of database interaction, the // styles dialog calls Save() before performing the rename/delete. This // ends the undo task (it's not undoable), so we can't end it again or // add new actions to it m_UndoTaskHelper.Dispose(); m_cache.Save(); CreateUndoTaskHelper(); if (StylesRenamedOrDeleted != null) StylesRenamedOrDeleted(); } else { // This makes sure the style sheet gets reinitialized after a Redo command. if (m_cache.ActionHandlerAccessor != null) { m_cache.ActionHandlerAccessor.AddAction( new UndoStyleChangesAction(m_app, m_cache, false)); } } m_app.Synchronize(new SyncInfo(SyncMsg.ksyncStyle, 0, 0), m_cache); } else { // If nothing changed then we just pretend the user pressed Cancel. DialogResult = DialogResult.Cancel; } } finally { m_UndoTaskHelper.Dispose(); m_UndoTaskHelper = null; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create the given style if it doesn't already exist in the style sheet. /// </summary> /// <param name="xinfo">The OXES info.</param> /// <param name="fParaStyle">if set to <c>true</c> [f para style].</param> /// ------------------------------------------------------------------------------------ private void CreateCustomStyleIfNeeded(OxesInfo xinfo, bool fParaStyle) { string sCustom = xinfo.StyleName; if (String.IsNullOrEmpty(sCustom)) return; IStStyle sty = m_styleSheet.FindStyle(sCustom); if (sty == null) { Debug.WriteLine(String.Format("Creating {0} style \"{1}\"", fParaStyle ? "paragraph" : "character", sCustom)); IStStyle newStyle = new StStyle(m_cache, m_styleSheet.MakeNewStyle()); newStyle.Name = sCustom; if (fParaStyle) { newStyle.Type = StyleType.kstParagraph; switch (xinfo.Context) { case OxesContext.IntroSection: newStyle.BasedOnRA = m_styleSheet.FindStyle(ScrStyleNames.IntroSectionHead); break; case OxesContext.Introduction: newStyle.BasedOnRA = m_styleSheet.FindStyle(ScrStyleNames.IntroParagraph); break; case OxesContext.NormalSection: newStyle.BasedOnRA = m_styleSheet.FindStyle(ScrStyleNames.SectionHead); break; default: newStyle.BasedOnRA = m_styleSheet.FindStyle(ScrStyleNames.NormalParagraph); break; } } else { newStyle.Type = StyleType.kstCharacter; } string sUsage = String.Format(TeResourceHelper.GetResourceString("kstidStyleFromImport"), m_sOXESFile); m_styleSheet.PutStyle(sCustom, sUsage, newStyle.Hvo, newStyle.BasedOnRAHvo, newStyle.Hvo, (int)newStyle.Type, false, false, null); sty = m_styleSheet.FindStyle(sCustom); Debug.Assert(sty != null); } }
public void CreateAndLoadOwnedObject() { CheckDisposed(); StStyle style = new StStyle(); Cache.LangProject.StylesOC.Add(style); Guid guid = Cache.GetGuidFromId(style.Hvo); Assert.IsTrue(guid != Guid.Empty); }
public void TestReplaceFormerStyles() { CheckDisposed(); DummyTeStylesXmlAccessor acc = new DummyTeStylesXmlAccessor(m_scr, null); string headingStyleNameToDelete = null; string bodyStyleNameToDelete = null; foreach (IStStyle style in m_scr.StylesOC) { if (style.Context == ContextValues.Text) { if (style.Structure == StructureValues.Heading && style.Type == StyleType.kstParagraph && style.Name != ScrStyleNames.SectionHead) headingStyleNameToDelete = style.Name; else if (style.Structure == StructureValues.Body && style.Type == StyleType.kstParagraph && style.Name != ScrStyleNames.NormalParagraph) bodyStyleNameToDelete = style.Name; } if (headingStyleNameToDelete != null && bodyStyleNameToDelete != null) break; } Assert.IsNotNull(headingStyleNameToDelete, "Couldn't find a real style for test -- need to create a bogus heading para style"); Assert.IsNotNull(bodyStyleNameToDelete, "Couldn't find a real style for test -- need to create a bogus body para style"); StStyle styDeleteThisTitleStyle = new StStyle(); m_scr.StylesOC.Add(styDeleteThisTitleStyle); styDeleteThisTitleStyle.Name = "Auf wiedersehen"; styDeleteThisTitleStyle.Context = ContextValues.Title; styDeleteThisTitleStyle.Type = StyleType.kstParagraph; // Create a few paragraphs using some fake styles IScrBook book = m_scr.ScriptureBooksOS[0]; IScrSection sect = book.SectionsOS[0]; StTxtPara hPara0 = (StTxtPara)sect.HeadingOA.ParagraphsOS[0]; StTxtPara cPara0 = (StTxtPara)sect.ContentOA.ParagraphsOS[0]; StTxtPara tPara0 = (StTxtPara)book.TitleOA.ParagraphsOS[0]; book = m_scr.ScriptureBooksOS[1]; FdoOwningSequence<IScrSection> sections = book.SectionsOS; sect = sections[sections.Count - 1]; StTxtPara hPara1 = (StTxtPara)sect.HeadingOA.ParagraphsOS[0]; FdoOwningSequence<IStPara> paras = sect.ContentOA.ParagraphsOS; StTxtPara cPara1 = (StTxtPara)paras[paras.Count - 1]; StTxtPara tPara1 = (StTxtPara)book.TitleOA.ParagraphsOS[0]; // Change the paragraph style to something bogus ITsPropsBldr bldr = TsPropsBldrClass.Create(); bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "To Be Replaced"); ITsTextProps props = bldr.GetTextProps(); hPara0.StyleRules = props; cPara0.StyleRules = props; tPara0.StyleRules = props; bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, headingStyleNameToDelete); hPara1.StyleRules = bldr.GetTextProps(); bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, bodyStyleNameToDelete); cPara1.StyleRules = bldr.GetTextProps(); bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, styDeleteThisTitleStyle.Name); tPara1.StyleRules = bldr.GetTextProps(); // Add some runs using a bogus character style bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Wacky Char Style"); props = bldr.GetTextProps(); ITsStrBldr strBldr = hPara0.Contents.UnderlyingTsString.GetBldr(); strBldr.Replace(0, 0, "glub", props); hPara0.Contents.UnderlyingTsString = strBldr.GetString(); strBldr = cPara0.Contents.UnderlyingTsString.GetBldr(); strBldr.Replace(3, 3, "glub", props); cPara0.Contents.UnderlyingTsString = strBldr.GetString(); strBldr = tPara0.Contents.UnderlyingTsString.GetBldr(); strBldr.Replace(3, 3, "glub", props); tPara0.Contents.UnderlyingTsString = strBldr.GetString(); bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Be Gone"); props = bldr.GetTextProps(); strBldr = hPara1.Contents.UnderlyingTsString.GetBldr(); strBldr.Replace(3, 3, "glub", props); hPara1.Contents.UnderlyingTsString = strBldr.GetString(); strBldr = cPara1.Contents.UnderlyingTsString.GetBldr(); strBldr.Replace(3, 3, "glub", props); cPara1.Contents.UnderlyingTsString = strBldr.GetString(); // Simulate a paragraph style replacement acc.ReplacedStyles.Add(new StyleReplacement("To Be Replaced", "With This")); acc.ReplacedStyles.Add(new StyleReplacement("Wacky Char Style", "Sane Char Style")); acc.DeletedStyles.Add(headingStyleNameToDelete); acc.DeletedStyles.Add(bodyStyleNameToDelete); acc.DeletedStyles.Add(styDeleteThisTitleStyle.Name); acc.DeletedStyles.Add("Be Gone"); acc.CallReplaceFormerStyles(); // Check replaced paragraph style string styleName = hPara0.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual("With This", styleName); styleName = cPara0.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual("With This", styleName); styleName = tPara0.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual("With This", styleName); // Check deleted paragraph styles styleName = hPara1.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual(ScrStyleNames.SectionHead, styleName); styleName = cPara1.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual(ScrStyleNames.NormalParagraph, styleName); styleName = tPara1.StyleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual(ScrStyleNames.MainBookTitle, styleName); //Check replaced character style props = hPara0.Contents.UnderlyingTsString.get_PropertiesAt(4); styleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual("Sane Char Style", styleName); props = cPara0.Contents.UnderlyingTsString.get_PropertiesAt(4); styleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual("Sane Char Style", styleName); props = tPara0.Contents.UnderlyingTsString.get_PropertiesAt(4); styleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual("Sane Char Style", styleName); // Check deleted character styles props = hPara1.Contents.UnderlyingTsString.get_PropertiesAt(4); styleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual(null, styleName); props = cPara1.Contents.UnderlyingTsString.get_PropertiesAt(4); styleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual(null, styleName); props = tPara1.Contents.UnderlyingTsString.get_PropertiesAt(4); styleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle); Assert.AreEqual(null, styleName); }