Ejemplo n.º 1
0
        public void DeleteNewStyle()
        {
            int nStylesOrig = m_styleSheet.CStyles;

            // set up a proxy
            int wsVern             = Cache.DefaultVernWs;
            ImportStyleProxy proxy = new ImportStyleProxy("MyNewStyle",
                                                          StyleType.kstParagraph, wsVern, ContextValues.General, m_styleSheet);

            Assert.IsTrue(proxy.IsUnknownMapping, "MyNewStyle style not should exist in DB");

            // Besides returning the props, retrieval of TsTextProps forces creation of a real style
            // in stylesheet
            ITsTextProps ttps = proxy.TsTextProps;

            Assert.IsFalse(proxy.IsUnknownMapping, "style should be created when getting ParaProps");
            Assert.AreEqual(nStylesOrig + 1, m_styleSheet.CStyles);

            // get the hvo of the new style
            int hvoStyle = -1;

            for (int i = 0; i < m_styleSheet.CStyles; i++)
            {
                if (m_styleSheet.get_NthStyleName(i) == "MyNewStyle")
                {
                    hvoStyle = m_styleSheet.get_NthStyle(i);
                }
            }
            Assert.IsTrue(hvoStyle != -1, "Style 'MyNewStyle' should exist in DB");

            // 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");
        }