public void CreateProxyForDecomposedStyleWhenExistingStyleIsComposed() { int hvoStyle = m_styleSheet.MakeNewStyle(); m_styleSheet.PutStyle("\u0100", "Test", hvoStyle, 0, 0, (int)StyleType.kstParagraph, false, false, null); int cStylesOrig = m_styleSheet.CStyles; ImportStyleProxy proxy1 = new ImportStyleProxy("\u0041\u0304", StyleType.kstParagraph, Cache.DefaultVernWs, ContextValues.Text, m_styleSheet); Assert.IsFalse(proxy1.IsUnknownMapping, "style should exist in DB"); Assert.AreEqual(cStylesOrig, m_styleSheet.CStyles); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add a new real style in the stylesheet for this proxy, if needed. /// </summary> /// ------------------------------------------------------------------------------------ private void AddStyleToStylesheet() { if (m_style != null || m_Context == ContextValues.EndMarker || m_sStyleName == null) { return; } // If m_ttpFormattingProps has not been set up, initialize it now if (m_ttpFormattingProps == null) { ITsPropsBldr tsPropsBldr = TsStringUtils.MakePropsBldr(); m_ttpFormattingProps = tsPropsBldr.GetTextProps(); // default properties } // Get an hvo for the new style int hvoStyle = m_LcmStyleSheet.MakeNewStyle(); m_style = m_LcmStyleSheet.Cache.ServiceLocator.GetInstance <IStStyleRepository>().GetObject(hvoStyle); // PutStyle() adds the style to the stylesheet. we'll give it the properties we // are aware of. m_LcmStyleSheet.PutStyle(m_sStyleName, string.Empty, hvoStyle, 0, m_StyleType == StyleType.kstParagraph ? hvoStyle : 0, (int)m_StyleType, false, false, m_ttpFormattingProps); // base the new style on "Paragraph" if (m_StyleType == StyleType.kstParagraph) { m_style.BasedOnRA = m_LcmStyleSheet.FindStyle(ScrStyleNames.NormalParagraph); m_style.Context = m_style.BasedOnRA.Context; m_style.Structure = m_style.BasedOnRA.Structure; m_style.Function = m_style.BasedOnRA.Function; } }