Ejemplo n.º 1
0
        public void TestGetStyleRgch()
        {
            IVwStylesheet stylesheet = new TestFwStylesheet();
            ITsPropsBldr  propsBldr  = TsStringUtils.MakePropsBldr();

            propsBldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Times");
            ITsTextProps props1 = propsBldr.GetTextProps();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptForeColor,
                                       (int)FwTextPropVar.ktpvDefault, 256);
            ITsTextProps props2       = propsBldr.GetTextProps();
            int          hvoNewStyle1 = stylesheet.MakeNewStyle();

            stylesheet.PutStyle("FirstStyle", "bla", hvoNewStyle1, 0, hvoNewStyle1, 0, false,
                                false, props1);
            int hvoNewStyle2 = stylesheet.MakeNewStyle();

            stylesheet.PutStyle("SecondStyle", "bla", hvoNewStyle2, 0, hvoNewStyle1, 0, false,
                                false, props2);
            string sHowDifferent;
            bool   fEqual = TsTextPropsHelper.PropsAreEqual(props2,
                                                            stylesheet.GetStyleRgch(0, "SecondStyle"), out sHowDifferent);

            Assert.IsTrue(fEqual, sHowDifferent);
            fEqual = TsTextPropsHelper.PropsAreEqual(props1,
                                                     stylesheet.GetStyleRgch(0, "FirstStyle"), out sHowDifferent);
            Assert.IsTrue(fEqual, sHowDifferent);
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares the given footnote with the values in m_footnote.
        /// </summary>
        /// <param name="footnote">The footnote to compare</param>
        /// ------------------------------------------------------------------------------------
        private void CompareFootnote(IStFootnote footnote)
        {
            Assert.AreEqual(m_footnote.MarkerType, footnote.MarkerType);
            if (footnote.MarkerType == FootnoteMarkerTypes.SymbolicFootnoteMarker)
            {
                AssertEx.AreTsStringsEqual(m_footnote.FootnoteMarker, footnote.FootnoteMarker);
            }
            Assert.AreEqual(m_footnote.ParagraphsOS.Count, footnote.ParagraphsOS.Count,
                            "Footnote paragraph count did not match");

            string diff = string.Empty;

            for (int i = 0; i < m_footnote.ParagraphsOS.Count; i++)
            {
                IStTxtPara expectedPara = (IStTxtPara)m_footnote.ParagraphsOS[i];
                IStTxtPara actualPara   = (IStTxtPara)footnote.ParagraphsOS[i];
                bool       result       = TsTextPropsHelper.PropsAreEqual(expectedPara.StyleRules,
                                                                          actualPara.StyleRules, out diff);
                Assert.IsTrue(result, "paragraph " + i + " stylerules differed in: " + diff);

                result = TsStringHelper.TsStringsAreEqual(expectedPara.Contents,
                                                          actualPara.Contents, out diff);
                Assert.IsTrue(result, "paragraph " + i + " differed in: " + diff);

                CompareFootnoteTrans(expectedPara.GetBT(), actualPara);
            }
        }
Ejemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares the given footnote with the values in m_footnote.
        /// </summary>
        /// <param name="footnote">The footnote to compare</param>
        /// ------------------------------------------------------------------------------------
        private void CompareFootnote(StFootnote footnote)
        {
            Assert.AreEqual(m_footnote.DisplayFootnoteMarker, footnote.DisplayFootnoteMarker,
                            "Display footnote marker values did not match");
            Assert.AreEqual(m_footnote.DisplayFootnoteReference, footnote.DisplayFootnoteReference,
                            "Display footnote reference values did not match");
            Assert.AreEqual(m_footnote.FootnoteMarker.Text, footnote.FootnoteMarker.Text);
            Assert.AreEqual(m_footnote.ParagraphsOS.Count, footnote.ParagraphsOS.Count,
                            "Footnote paragraph count did not match");

            string diff = string.Empty;

            for (int i = 0; i < m_footnote.ParagraphsOS.Count; i++)
            {
                StTxtPara expectedPara = (StTxtPara)m_footnote.ParagraphsOS[i];
                StTxtPara actualPara   = (StTxtPara)footnote.ParagraphsOS[i];
                bool      result       = TsTextPropsHelper.PropsAreEqual(expectedPara.StyleRules,
                                                                         actualPara.StyleRules, out diff);
                Assert.IsTrue(result, "paragraph " + i + " stylerules differed in: " + diff);

                result = TsStringHelper.TsStringsAreEqual(expectedPara.Contents.UnderlyingTsString,
                                                          actualPara.Contents.UnderlyingTsString, out diff);
                Assert.IsTrue(result, "paragraph " + i + " differed in: " + diff);

                CompareFootnoteTrans((CmTranslation)expectedPara.GetBT(), (CmTranslation)actualPara.GetBT(),
                                     actualPara.Hvo);
            }
        }
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Tests that the given run of the given ITsStrBldr contains the specified text
        /// and properties.
        /// </summary>
        /// <param name="iRun">zero-based run index</param>
        /// <param name="text">Expected run text</param>
        /// <param name="charStyleName">character style name, or null if expecting default
        /// paragraph character props</param>
        /// <param name="wsExpected">expected writing system for the run</param>
        /// <param name="strBldr">the string builder in which to verify the run</param>
        /// ------------------------------------------------------------------------------------
        protected void VerifyBldrRun(int iRun, string text, string charStyleName, int wsExpected,
                                     ITsStrBldr strBldr)
        {
            s_strBldr = strBldr;

            Assert.AreEqual(text, s_strBldr.get_RunText(iRun));
            ITsTextProps ttpExpected = CharStyleTextProps(charStyleName, wsExpected);
            ITsTextProps ttpRun      = s_strBldr.get_Properties(iRun);
            string       sWhy;

            if (!TsTextPropsHelper.PropsAreEqual(ttpExpected, ttpRun, out sWhy))
            {
                Assert.Fail(sWhy);
            }
        }