Example #1
0
        public void AddDeleteStyle()
        {
            var tsPropsBldr        = TsPropsBldrClass.Create();
            var ttpFormattingProps = tsPropsBldr.GetTextProps();             // default properties
            var nStylesOrig        = m_styleSheet.CStyles;

            // get an hvo for the new style
            var hvoStyle = m_styleSheet.MakeNewStyle();
            var style    = Cache.ServiceLocator.GetInstance <IStStyleRepository>().GetObject(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
            var 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");
        }