예제 #1
0
        public void DefaultFontAndLineHeightUsed()
        {
            m_pub.BaseFontSize    = 0;
            m_pub.BaseLineSpacing = 0;
            m_inMemoryCache.CreateDefaultLangProjStyles();
            FwStyleSheet stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, Cache.LangProject.Hvo,
                            (int)LangProject.LangProjectTags.kflidStyles);

            DummyDivision       divLayoutMgr = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1);
            ReallyStupidPubCtrl pubControl   = new ReallyStupidPubCtrl(m_pub, stylesheet,
                                                                       divLayoutMgr, DateTime.Now, true);
            ITsTextProps normalProps = pubControl.PrintLayoutStylesheet.GetStyleRgch(-1, "Normal");

            Assert.IsNotNull(normalProps);
            int var;

            Assert.AreEqual(pubControl.DefaultFontSize,
                            normalProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var));
            Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var);
            Assert.AreEqual(pubControl.DefaultLineHeight,
                            normalProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out var));
            Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var);
        }
예제 #2
0
        // Return true if a spelling error occurs in the word that is the specified substring of m_text.
        bool CheckWord(int ichMinWord, int ichLimWord)
        {
            string       word = TsStringUtils.NormalizeToNFC(m_text.Substring(ichMinWord, ichLimWord - ichMinWord));
            TsRunInfo    tri;
            ITsTextProps props = m_tss.FetchRunInfoAt(ichMinWord, out tri);
            int          var;
            int          ws            = props.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
            bool         fFoundOurWs   = (ws == m_ws);
            bool         fFoundOtherWs = (ws != m_ws);

            while (tri.ichLim < ichLimWord)
            {
                props          = m_tss.FetchRunInfoAt(tri.ichLim, out tri);
                ws             = props.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
                fFoundOurWs   |= (ws == m_ws);
                fFoundOtherWs |= (ws != m_ws);
            }
            if (!fFoundOurWs)
            {
                return(false);                // don't check words with nothing in interesting WS.
            }
            if (fFoundOtherWs)
            {
                return(true);                // mixed writing system in a 'word' always counts as a 'spelling' error.
            }
            return(!m_dict.Check(word));     // succeed if check fails!
        }
예제 #3
0
        public void PublicationFontAndLineHeightUsed()
        {
            m_pub.BaseFontSize    = 9000;
            m_pub.BaseLineSpacing = -11000;
            FwStyleSheet stylesheet = new FwStyleSheet();

            stylesheet.Init(Cache, Cache.LangProject.TranslatedScriptureOA.Hvo,
                            ScriptureTags.kflidStyles);

            using (DummyDivision divLayoutMgr = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1))
            {
                using (ReallyStupidPubCtrl pubControl = new ReallyStupidPubCtrl(m_pub, stylesheet,
                                                                                divLayoutMgr, DateTime.Now, true))
                {
                    ITsTextProps normalProps = pubControl.PrintLayoutStylesheet.GetStyleRgch(-1, "Normal");
                    Assert.IsNotNull(normalProps);
                    int var;
                    Assert.AreEqual(9000,
                                    normalProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var));
                    Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var);
                    Assert.AreEqual(-11000,
                                    normalProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out var));
                    Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var);
                }
            }
        }
예제 #4
0
        public void NoTextScaling()
        {
            // Set up a ScripturePublication with no scaling specified.
            m_pub.Name                      = "Scripture Draft";
            m_pub.BaseFontSize              = 0;
            m_pub.BaseLineSpacing           = 0;
            m_pub.PageHeight                = 0;
            m_pub.PageWidth                 = 0;
            m_pub.PaperHeight               = 0;
            m_pub.PaperWidth                = 0;
            m_pub.DivisionsOS[0].NumColumns = 2;
            IVwStylesheet stylesheet;
            int           nVar;

            using (DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                       TeViewType.Scripture | TeViewType.PrintLayout, m_realStylesheet))
            {
                stylesheet = scrPub.StyleSheet;
                ITsTextProps ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
                // We expect that the normal style will be unchanged.
                Assert.AreEqual(10000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
                Assert.AreEqual(-12000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            }

            // We expect that these styles that have specific font sizes will have their original values.
            ITsTextProps styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);

            Assert.AreEqual(9000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(8000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(9000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(20000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));

            // We expect that these styles with specific line heights will have their original values.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalFootnoteParagraph);
            Assert.AreEqual(10000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);
            Assert.AreEqual(-11000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(-10000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(-24000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));

            // We expect that these styles will have their original space before/after at values.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(36000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(12000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(8000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(4000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
예제 #5
0
        public void DefaultTextScaling_OneColFullPgStdBibleSize()
        {
            m_pub.Name                      = "Scripture Draft";
            m_pub.BaseFontSize              = 0;
            m_pub.BaseLineSpacing           = 0;
            m_pub.PaperHeight               = (int)(8.7 * 72000);
            m_pub.PaperWidth                = (int)(5.8 * 72000);
            m_pub.PageHeight                = 0;
            m_pub.PageWidth                 = 0;
            m_pub.DivisionsOS[0].NumColumns = 1;
            IVwStylesheet stylesheet;
            int           nVar;

            using (DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                       TeViewType.Scripture | TeViewType.PrintLayout, m_realStylesheet))
            {
                stylesheet = scrPub.StyleSheet;
                ITsTextProps ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
                // We expect that the normal style will be bumped up to the official IPUB sizes for
                // a one-column publication.
                Assert.AreEqual(11000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
                Assert.AreEqual(-13000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            }

            // We expect that these styles that have specific font sizes will have their original values.
            ITsTextProps styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);

            Assert.AreEqual(10000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(9000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(10000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(22000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));

            // We expect that these styles with specific line heights will have their original values.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalFootnoteParagraph);
            Assert.AreEqual(10833, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);
            Assert.AreEqual(-11917, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(-10833, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(-26000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));

            // We expect that these styles will have their original space before/after at values.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(39000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(13000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(8667, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(4333, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
예제 #6
0
        public void SmallTextScaling()
        {
            // Set up a ScripturePublication of 4 on 6 pts (base character size on line spacing).
            m_pub.BaseFontSize    = 4000;
            m_pub.BaseLineSpacing = -6000;
            InMemoryStyleSheet stylesheet;
            int nVar;

            using (DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                       TeViewType.Scripture | TeViewType.PrintLayout, m_realStylesheet))
            {
                stylesheet = scrPub.StyleSheet as InMemoryStyleSheet;
                Assert.IsNotNull(stylesheet);

                ITsTextProps ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
                // We expect that the normal style will have specified settings for the publication.
                Assert.AreEqual(4000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
                Assert.AreEqual(-6000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            }

            // We expect that these styles will be overridden for font size at 40% their original size.
            ITsTextProps styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);

            Assert.AreEqual(4000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(4000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(4000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(8000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));

            // We expect that these styles will be overridden for line spacing at 50% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalFootnoteParagraph);
            Assert.AreEqual(5000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);
            Assert.AreEqual(-5500, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(-5000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(-12000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));

            // We expect that these styles will be overridden for space before/after at 50% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(18000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(6000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(4000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(2000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
예제 #7
0
        public void CorrectionPrintoutLineSpacing()
        {
            // Set up a ScripturePublication with no scaling specified.
            m_pub.BaseFontSize    = 12000;
            m_pub.BaseLineSpacing = -36000;
            IVwStylesheet stylesheet;
            int           nVar;

            using (DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                       TeViewType.Correction, m_realStylesheet))
            {
                stylesheet = scrPub.StyleSheet;
                ITsTextProps ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
                // We expect that the normal style will have specified settings for the publication.
                Assert.AreEqual(12000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
                Assert.AreEqual(-36000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            }

            // We expect that these styles will be overridden for font size at 120% their original size.
            ITsTextProps styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);

            Assert.AreEqual(11000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(10000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(11000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(24000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));

            // We expect these styles to be overridden for line spacing to exactly 36 pts.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalFootnoteParagraph);
            Assert.AreEqual(-36000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);
            Assert.AreEqual(-36000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(-36000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(-36000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));

            // We expect that these styles will have unchanged space before/after values.
            // REVIEW: Should we zero out any space before or after for the correction printout view to
            // achieve consistent line spacing?
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(36000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(12000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(8000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(4000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
예제 #8
0
        public void LargeTextScaling()
        {
            // Set up a ScripturePublication of 14 on 16 pts (base character size on line spacing).
            // (Original size is for 10 on 12).
            m_pub.BaseFontSize    = 14000;
            m_pub.BaseLineSpacing = -16000;
            IVwStylesheet stylesheet;
            int           nVar;

            using (DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                       TeViewType.Scripture | TeViewType.PrintLayout, m_realStylesheet))
            {
                stylesheet = scrPub.StyleSheet;
                ITsTextProps ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
                // We expect that the normal style will have specified settings for the publication.
                Assert.AreEqual(14000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
                Assert.AreEqual(-16000,
                                ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            }

            // We expect that these styles will be overridden for font size at 140% their original size.
            ITsTextProps styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);

            Assert.AreEqual(13000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(11000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(13000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(28000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));

            // We expect that these styles will be overridden for font size at 133% their original size
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalFootnoteParagraph);
            Assert.AreEqual(13333, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);
            Assert.AreEqual(-14667, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(-13333, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(-32000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));

            // We expect that these styles will be overridden for space before/after at 133% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(48000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(16000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(10667, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(5333, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
예제 #9
0
        public void NormalTextScaling()
        {
            // Set up a ScripturePublication of 9 on 11 pts (base character size on line spacing).
            m_pub.BaseFontSize    = 9000;
            m_pub.BaseLineSpacing = -11000;
            DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                TeViewType.Scripture | TeViewType.PrintLayout, m_realStylesheet);
            IVwStylesheet stylesheet    = scrPub.StyleSheet;
            ITsTextProps  ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
            int           nVar;

            // We expect that the normal style will have specified settings for the publication.
            Assert.AreEqual(9000,
                            ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            Assert.AreEqual(-11000,
                            ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            scrPub.Dispose();

            // We expect that these styles will be overridden for font size at 90% their original size.
            ITsTextProps styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);

            Assert.AreEqual(8000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(7000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(8000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(18000, styleProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));

            // We expect these styles to be overridden for line spacing at 91.667% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalFootnoteParagraph);
            Assert.AreEqual(9167, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);
            Assert.AreEqual(-10083, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroSectionHead);
            Assert.AreEqual(-9167, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(-22000, styleProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));

            // We expect that these styles will be overridden for space before/after at 91.667% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(33000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(11000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(7333, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(3667, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
예제 #10
0
 public override void Display(IVwEnv vwenv, int hvo, int frag)
 {
     CheckDisposed();
     if (m_wsDefault == -1)
     {
         // Set the underlying paragraph to RTL if the first writing system in the
         // string is RTL.
         if (m_cache != null)
         {
             ITsString    tss = m_cache.MainCacheAccessor.get_StringProp(hvo, m_flid);
             ITsTextProps ttp = tss.get_Properties(0);
             int          var;
             int          ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
             if (ws != 0)
             {
                 SetParaRTLIfNeeded(vwenv, ws);
             }
         }
         vwenv.AddStringProp(m_flid, this);
     }
     else
     {
         SetParaRTLIfNeeded(vwenv, m_wsDefault);
         vwenv.AddStringAltMember(m_flid, m_wsDefault, this);
     }
 }
예제 #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Answer the spelling status of the indicated character in the string, unless it is an
        /// ORC, in which case, for each ORC we answer a different value (that is not any of the
        /// valid spelling statuses).
        /// Enhance JohnT: we don't want to consider embedded-picture ORCs to count as
        /// different; we may strip them out before we start checking the word.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        int SpellCheckProps(ITsString tss, int ich, IVwStylesheet styles)
        {
            // For our purposes here, ORC (0xfffc) is considered to have a different spelling status from everything else,
            // even from every other ORC in the string. This means we always offer to insert spaces adjacent to them.
            if (ich < tss.Length && tss.GetChars(ich, ich + 1)[0] == 0xfffc)
            {
                return(-50 - ich);
            }
            ITsTextProps props = tss.get_PropertiesAt(ich);
            string       style = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
            int          var, val;

            if (styles != null && !string.IsNullOrEmpty(style))
            {
                ITsTextProps styleProps = styles.GetStyleRgch(style.Length, style);
                if (styleProps != null)
                {
                    val = styleProps.GetIntPropValues((int)FwTextPropType.ktptSpellCheck, out var);
                    if (var != -1)
                    {
                        return(val);                        // style overrides
                    }
                }
            }
            val = props.GetIntPropValues((int)FwTextPropType.ktptSpellCheck, out var);
            if (var == -1)
            {
                return(0);                // treat unspecified the same as default.
            }
            else
            {
                return(val);
            }
        }
예제 #12
0
        private void spyOnTextProps(ITsTextProps ttp)
        {
            int tpt;             // ??

            // look at integer props
            int cintProps = ttp.IntPropCount;

            for (int i = 0; i < cintProps; i++)
            {
                int nVar;
                int intProp = ttp.GetIntProp(i, out tpt, out nVar);
                int Value   = ttp.GetIntPropValues(tpt, out nVar);
                Value = 34;                 // need something so Value can be looked at
            }

            // look at string props
            int cstrProps = ttp.StrPropCount;

            for (int i = 0; i < cstrProps; i++)
            {
                string strProp = ttp.GetStrProp(i, out tpt);
                string Value   = ttp.GetStrPropValue(tpt);
                Value = "why?";                 // need something so Value can be looked at
            }
        }
예제 #13
0
        public void TypingBeforeHyperlink_WithPrecedingItalicsText()
        {
            var selection = MakeMockSelection(false);
            var selHelper = SelectionHelper.s_mockedSelectionHelper =
                MockRepository.GenerateStub <SelectionHelper>();

            selHelper.Stub(selH => selH.Selection).Return(selection);

            ITsPropsBldr bldr = m_ttpNormal.GetBldr();

            bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Italics");
            SimulateTextFollowedByHyperlink(selHelper, bldr.GetTextProps(),
                                            IchPosition.StartOfHyperlink, IchPosition.StartOfHyperlink);

            using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks))
            {
                editingHelper.OnKeyPress(new KeyPressEventArgs('b'), Keys.None);

                IList <object[]> argsSentToSetTypingProps =
                    selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null));
                Assert.AreEqual(1, argsSentToSetTypingProps.Count);
                ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0];
                Assert.AreEqual(1, ttpSentToSetTypingProps.StrPropCount);
                Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount);
                int nVar;
                Assert.AreEqual("Italics", ttpSentToSetTypingProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
                Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar));
            }
        }
예제 #14
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns the writing system of the specified ITsTextProps of a character style
        /// </summary>
        /// <param name="charStyleTextProps">The ITsTextProps</param>
        /// <returns>The writing system value</returns>
        /// ------------------------------------------------------------------------------------
        public static int WritingSystem(ITsTextProps charStyleTextProps)
        {
            int nVar = 0;

            return(charStyleTextProps.GetIntPropValues((int)FwTextPropType.ktptWs,
                                                       out nVar));
        }
예제 #15
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determines whether the specified string is editable.
        /// </summary>
        /// <param name="tss">The string.</param>
        /// <param name="ichMin">The ich min.</param>
        /// <param name="ichLim">The ich lim.</param>
        /// <returns>
        ///     <c>true</c> if the specified string is editable; otherwise, <c>false</c>.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        private bool IsEditable(ITsString tss, int ichMin, int ichLim)
        {
            if (m_fReadOnly)
            {
                return(false);
            }

            int irunLim = tss.get_RunAt(ichLim);

            if (tss.get_RunAt(ichMin) == irunLim)
            {
                irunLim++;
            }
            for (int irun = tss.get_RunAt(ichMin); irun < irunLim; irun++)
            {
                ITsTextProps ttp = tss.get_Properties(irun);
                int          nVar;
                if (ttp != null)
                {
                    int nVal = ttp.GetIntPropValues((int)FwTextPropType.ktptEditable, out nVar);
                    if (nVal == (int)TptEditable.ktptNotEditable ||
                        nVal == (int)TptEditable.ktptSemiEditable)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
예제 #16
0
        public void DeletingHyperlink_LinkButNotPrecedingText()
        {
            var selection = MakeMockSelection();
            var selHelper = SelectionHelper.s_mockedSelectionHelper =
                MockRepository.GenerateStub <SelectionHelper>();

            selHelper.Stub(selH => selH.Selection).Return(selection);

            SimulatePlainTextFollowedByHyperlink(selHelper, IchPosition.StartOfHyperlink,
                                                 IchPosition.EndOfHyperlink);

            using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks))
            {
                editingHelper.HandleKeyPress((char)(int)VwSpecialChars.kscDelForward, Keys.None);

                IList <object[]> argsSentToSetTypingProps =
                    selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null));
                Assert.AreEqual(1, argsSentToSetTypingProps.Count);
                ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0];
                Assert.AreEqual(0, ttpSentToSetTypingProps.StrPropCount);
                Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount);
                int nVar;
                Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar));
            }
        }
예제 #17
0
        public void OverTypingHyperlink_LinkPluSFollowingText_WholeParagraphSelected()
        {
            var selection = MakeMockSelection();
            var selHelper = SelectionHelper.s_mockedSelectionHelper =
                MockRepository.GenerateStub <SelectionHelper>();

            selHelper.Stub(selH => selH.Selection).Return(selection);

            SimulateHyperlinkFollowedByPlainText(selHelper, IchPosition.StartOfString,
                                                 IchPosition.EndOfString);

            using (FwEditingHelper editingHelper = new FwEditingHelper(Cache, m_callbacks))
            {
                editingHelper.OnKeyPress(new KeyPressEventArgs('b'), Keys.None);

                IList <object[]> argsSentToSetTypingProps =
                    selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null));
                Assert.AreEqual(1, argsSentToSetTypingProps.Count);
                ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0];
                Assert.AreEqual(0, ttpSentToSetTypingProps.StrPropCount);
                Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount);
                int nVar;
                Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar));
            }
        }
예제 #18
0
        /// <summary>
        /// Handle fixing the writing system values inside pasted text.  Eventually, we may
        /// want some form of UI to guide the process, but for now we just bash in the
        /// default vernacular ws wherever any other ws occurs.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnPasteFixWs(EditingHelper sender, FwPasteFixTssEventArgs args)
        {
            if (args.EventHandled)
            {
                return;                                                 // only one delegate gets to play!
            }
            bool       fFixed = false;
            int        wsVern = Cache.LangProject.ActualWs(LangProject.kwsVernInParagraph, m_hvoRoot, (int)StText.StTextTags.kflidParagraphs);
            ITsStrBldr tsb    = args.TsString.GetBldr();
            int        crun   = tsb.RunCount;

            for (int irun = 0; irun < crun; ++irun)
            {
                ITsTextProps ttp = tsb.get_Properties(irun);
                int          var;
                int          ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
                if (ws != wsVern)
                {
                    fFixed = true;
                    int ichMin;
                    int ichLim;
                    tsb.GetBoundsOfRun(irun, out ichMin, out ichLim);
                    tsb.SetIntPropValues(ichMin, ichLim,
                                         (int)FwTextPropType.ktptWs, var, wsVern);
                }
            }
            if (fFixed)
            {
                args.TsString = tsb.GetString();
            }
            args.EventHandled = true;
        }
        private int GetWsFromTsString(ITsString tss)
        {
            ITsTextProps ttp = tss.get_PropertiesAt(0);
            int          var;

            return(ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var));
        }
예제 #20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the font for the specified TsString and writing system.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private Font GetValuesFont(ITsString tss, int ws)
        {
            if (tss == null || tss.RunCount == 0 || m_cache == null)
            {
                return(null);
            }

            ITsTextProps ttp = tss.get_Properties(0);

            // Figure out what the font size of the string should be.
            int var;
            int fontSize = ttp.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var);

            if (fontSize == -1)
            {
                fontSize = FontInfo.kDefaultFontSize;
            }

            // Font size, at this point, is in millipoints, so convert it to points.
            fontSize /= 1000;

            // Figure out what the style name is and use it to get the font face name.
            string styleName = ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
            string faceName;

            if (m_styleSheet != null)
            {
                // When there is a stylesheet, use it to get the font face name for the style
                // name specified in the text props. If there is no style name in the text props,
                // GetFaceNameFromStyle() should return the font face for the normal style.
                faceName = m_styleSheet.GetFaceNameFromStyle(styleName, ws, m_cache);
            }
            else
            {
                // When there is no stylesheet, use the default serif font for the writing
                // system.
                IWritingSystem iws =
                    m_cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws);

                faceName = iws.DefaultSerif;
            }

            if (string.IsNullOrEmpty(faceName))
            {
                return(null);
            }

            // Check if the font is in our font cache. If not, add it.
            string key = string.Format("{0}{1}", faceName, fontSize);
            Font   fnt;

            if (!m_fontCache.TryGetValue(key, out fnt))
            {
                fnt = new Font(faceName, (float)fontSize, GraphicsUnit.Point);
                m_fontCache[key] = fnt;
            }

            return(fnt);
        }
예제 #21
0
        public void get_PropertiesAt_Empty_ReturnsCorrectProperties()
        {
            TsString     tss = CreateEmptyString();
            ITsTextProps tps = tss.get_PropertiesAt(0);
            int          var;

            Assert.That(tps.GetIntPropValues((int)FwTextPropType.ktptWs, out var), Is.EqualTo(EnglishWS));
        }
예제 #22
0
        public void get_PropertiesAt_TwoRuns_ReturnsCorrectProperties()
        {
            TsString     tss = CreateTwoRunString();
            ITsTextProps tps = tss.get_PropertiesAt(20);
            int          var;

            Assert.That(tps.GetIntPropValues((int)FwTextPropType.ktptWs, out var), Is.EqualTo(SpanishWS));
        }
예제 #23
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the font for the specified TsString and writing system.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private Font GetValuesFont(ITsString tss, int ws)
        {
            if (tss == null || tss.RunCount == 0 || m_cache == null)
            {
                return(null);
            }

            ITsTextProps ttp = tss.get_Properties(0);

            // Figure out what the font size of the string should be.
            int var;
            int fontSize = ttp.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var);

            if (fontSize == -1)
            {
                fontSize = FontInfo.kDefaultFontSize;
            }
            else
            {
                // Font size, at this point, is in millipoints, so convert it to points.
                fontSize /= 1000;
            }
            // Figure out what the style name is and use it to get the font face name.
            string styleName = ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
            string faceName;

            if (m_styleSheet != null)
            {
                using (var font = FontHeightAdjuster.GetFontForStyle(styleName, m_styleSheet, ws, m_cache.WritingSystemFactory))
                {
                    faceName = font == null ? null : font.Name;
                }
            }
            else
            {
                // When there is no stylesheet, use the default serif font for the writing
                // system.
                faceName = m_cache.ServiceLocator.WritingSystemManager.Get(ws).DefaultFontName;
            }

            if (string.IsNullOrEmpty(faceName))
            {
                return(null);
            }

            // Check if the font is in our font cache. If not, add it.
            string key = string.Format("{0}{1}", faceName, fontSize);
            Font   fnt;

            if (!m_fontCache.TryGetValue(key, out fnt))
            {
                fnt = new Font(faceName, fontSize, GraphicsUnit.Point);
                m_fontCache[key] = fnt;
            }

            return(fnt);
        }
예제 #24
0
            ///----------------------------------------------------------------------------------
            /// <summary>
            /// Asserts that the writing system is equal to the expected WS for the specified run.
            /// </summary>
            ///----------------------------------------------------------------------------------
            public void WsEqual(int expectedWs, ITsString tss, int iRun)
            {
                ITsTextProps props = GetProperties(tss, iRun);

                Assert.AreEqual(1, props.IntPropCount);
                int var;

                Assert.AreEqual(expectedWs, props.GetIntPropValues((int)FwTextPropType.ktptWs, out var));
            }
예제 #25
0
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// Make sure that all runs of the given ts string will fit within the given height.
        /// </summary>
        /// <param name="tss">(Potentially) unadjusted TsString -- may have some pre-existing
        /// adjustments, but if it does, we (probably) ignore those and recheck every run</param>
        /// <param name="dympMaxHeight">The maximum height (in millipoints) of the Ts String.</param>
        /// <param name="styleSheet"></param>
        /// <param name="writingSystemFactory"></param>
        /// -------------------------------------------------------------------------------------
        public static ITsString GetAdjustedTsString(ITsString tss, int dympMaxHeight,
                                                    IVwStylesheet styleSheet, ILgWritingSystemFactory writingSystemFactory)
        {
            if (dympMaxHeight == 0)
            {
                return(tss);
            }

            ITsStrBldr bldr = null;

            int runCount = tss.RunCount;

            for (int irun = 0; irun < runCount; irun++)
            {
                ITsTextProps props = tss.get_Properties(irun);
                int          var;
                int          wsTmp = props.GetIntPropValues((int)FwTextPropType.ktptWs,
                                                            out var);
                string styleName =
                    props.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle);

                Font f         = GetFontForStyle(styleName, styleSheet, wsTmp, writingSystemFactory);
                int  height    = GetFontHeight(f);
                int  curHeight = height;
                // incrementally reduce the size of the font until the text can fit
                while (curHeight > dympMaxHeight)
                {
                    f         = new Font(f.Name, f.SizeInPoints - 0.25f);
                    curHeight = GetFontHeight(f);
                }

                if (curHeight != height)
                {
                    // apply formatting to the problem run
                    if (bldr == null)
                    {
                        bldr = tss.GetBldr();
                    }

                    int iStart = tss.get_MinOfRun(irun);
                    int iEnd   = tss.get_LimOfRun(irun);
                    bldr.SetIntPropValues(iStart, iEnd,
                                          (int)FwTextPropType.ktptFontSize,
                                          (int)FwTextPropVar.ktpvMilliPoint, (int)(f.SizeInPoints * 1000.0f));
                }
            }

            if (bldr != null)
            {
                return(bldr.GetString());
            }
            else
            {
                return(tss);
            }
        }
예제 #26
0
        public void GetFootnoteMarkerFromGuid()
        {
            IScrFootnote footnote = Cache.ServiceLocator.GetInstance <IScrFootnoteFactory>().Create();

            m_scr.ScriptureBooksOS[0].FootnotesOS.Add(footnote);
            footnote.FootnoteMarker = Cache.TsStrFactory.MakeString("a", Cache.WritingSystemFactory.GetWsFromStr("en"));

            // Add the guid property so we can get it out as a string.
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            byte[] objData = TsStringUtils.GetObjData(footnote.Guid, 1);
            propsBldr.SetStrPropValueRgch(1, objData, objData.Length);

            // Get the guid property as a string.
            string sObjData;

            propsBldr.GetStrPropValue(1, out sObjData);

            StVc vc = new StVc(Cache.WritingSystemFactory.UserWs)
            {
                Cache = Cache
            };
            ITsString footnoteMarker = vc.GetStrForGuid(sObjData.Substring(1));

            // Call to GetStrForGuid doesn't generate a footnote marker based on the
            // Scripture Footnote properties since the method to do that is in TeStVc.
            int dummy;

            Assert.AreEqual(StringUtils.kszObject, footnoteMarker.Text);
            ITsTextProps props = footnoteMarker.get_Properties(0);

            Assert.AreEqual(2, props.IntPropCount);
            Assert.AreEqual(Cache.DefaultUserWs, props.GetIntPropValues((int)FwTextPropType.ktptWs, out dummy));
            Assert.AreEqual(0, props.GetIntPropValues((int)FwTextPropType.ktptEditable, out dummy));
            Assert.AreEqual(1, props.StrPropCount);

            FwObjDataTypes odt;
            Guid           footnoteGuid = TsStringUtils.GetGuidFromProps(props, null, out odt);

            Assert.IsTrue(odt == FwObjDataTypes.kodtPictEvenHot || odt == FwObjDataTypes.kodtPictOddHot);
            Assert.AreEqual(footnote.Guid, footnoteGuid);
        }
예제 #27
0
        /// <summary>
        /// Assert that the specified object has the specified string property, and that the string
        /// has the specified text property at the specified location.
        /// </summary>
        /// <param name="hvoObj"></param>
        /// <param name="flid"></param>
        /// <param name="ich"></param>
        /// <param name="tpt"></param>
        /// <param name="val"></param>
        void AssertTextProp(int hvoObj, int flid, int ich, int tpt, int val, string message)
        {
            ITsString tss = Cache.GetTsStringProperty(hvoObj, flid);

            Assert.IsTrue(tss.Length > ich, "String is too short (" + message + ")");
            ITsTextProps props = tss.get_PropertiesAt(ich);
            int          valActual, var;

            valActual = props.GetIntPropValues(tpt, out var);
            Assert.AreEqual(val, valActual, "String has wrong property value (" + message + ")");
        }
예제 #28
0
        public void MakeProps_NullStyle_CreatesTextPropsWithoutStyle()
        {
            var          tpf = new TsPropsFactory();
            ITsTextProps tps = tpf.MakeProps(null, 2, 1);

            Assert.That(tps.IntPropCount, Is.EqualTo(1));
            int var;

            Assert.That(tps.GetIntPropValues((int)FwTextPropType.ktptWs, out var), Is.EqualTo(2));
            Assert.That(var, Is.EqualTo(1));
            Assert.That(tps.StrPropCount, Is.EqualTo(0));
        }
예제 #29
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Checks the final space in reference label.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void CheckFinalSpaceInReferenceLabel(ITsString tss)
        {
            int iRun = tss.RunCount - 1;

            Assert.AreEqual(" ", tss.get_RunText(iRun));
            ITsTextProps ttp = tss.get_Properties(iRun);

            Assert.AreEqual(null, ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
            int var;

            Assert.AreEqual(Cache.WritingSystemFactory.UserWs,
                            ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var));
        }
예제 #30
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="XmlTextRun"/> class, based on the given
        /// run information
        /// </summary>
        /// <param name="wsDefault">The default writing system of the paragraph.</param>
        /// <param name="lgwsf">The writing system factory.</param>
        /// <param name="text">The text of the run.</param>
        /// <param name="props">The properties of the run.</param>
        /// ------------------------------------------------------------------------------------
        public XmlTextRun(int wsDefault, ILgWritingSystemFactory lgwsf, string text,
                          ITsTextProps props)
        {
            int dummy;
            int wsRun = props.GetIntPropValues((int)FwTextPropType.ktptWs, out dummy);

            if (wsRun != wsDefault)
            {
                IcuLocale = lgwsf.GetStrFromWs(wsRun);
            }
            StyleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
            m_text    = text;
        }
예제 #31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="XmlTextRun"/> class, based on the given
		/// run information
		/// </summary>
		/// <param name="wsDefault">The default writing system of the paragraph.</param>
		/// <param name="lgwsf">The writing system factory.</param>
		/// <param name="text">The text of the run.</param>
		/// <param name="props">The properties of the run.</param>
		/// ------------------------------------------------------------------------------------
		public XmlTextRun(int wsDefault, ILgWritingSystemFactory lgwsf, string text,
			ITsTextProps props)
		{
			int dummy;
			int wsRun = props.GetIntPropValues((int)FwTextPropType.ktptWs, out dummy);
			if (wsRun != wsDefault)
				IcuLocale = lgwsf.GetStrFromWs(wsRun);
			StyleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
			m_text = text;
		}
예제 #32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Scales the given property based on the scaling factor and sets it in the in-memory
		/// stylesheet.
		/// </summary>
		/// <param name="stylesheet">The in-memory stylesheet used for overriding properties.
		/// </param>
		/// <param name="scalingFactor">The scaling factor.</param>
		/// <param name="styleName">Name of the style.</param>
		/// <param name="styleProps">The style props.</param>
		/// <param name="prop">The type of property to be scaled.</param>
		/// ------------------------------------------------------------------------------------
		private static void ScaleProperty(InMemoryStyleSheet stylesheet,
			decimal scalingFactor, string styleName, ITsTextProps styleProps,
			FwTextPropType prop)
		{
			int var;
			int propValue = styleProps.GetIntPropValues((int)prop, out var);
			if (propValue != -1 && var == (int)FwTextPropVar.ktpvMilliPoint)
			{
				if (prop == FwTextPropType.ktptFontSize)
				{
					Debug.Assert(propValue >= 4);
					// Calculate new value for this style, rounding to reasonable value.
					propValue = ScaleAndRoundProp(scalingFactor, propValue, 1000);
					// Adjusted font size must be at least 4 pts
					propValue = Math.Max(propValue, 4000);
				}
				else
					propValue = ScaleAndRoundProp(scalingFactor, propValue, 1);

				stylesheet.AddIntPropOverride(styleName, prop,
					FwTextPropVar.ktpvMilliPoint, propValue);
			}
		}
예제 #33
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Add the given text and props as a new run to the end of the specified paragraph
		/// under construction.
		/// </summary>
		/// <param name="sText">Text to be appended to the paragraph being built</param>
		/// <param name="pttpProps">Properties (should contain only a named style) for the run
		/// of text to be added.</param>
		/// <param name="strbldr">String builder of paragraph being built</param>
		/// ------------------------------------------------------------------------------------
		protected void AddTextToPara(string sText, ITsTextProps pttpProps, ITsStrBldr strbldr)
		{
			// Don't bother trying to add empty runs. Also don't add runs consisting of a single
			// space if processing a marker that maps to a paragraph style.
			if (sText.Length > 0 &&
				(sText != " " || m_styleProxy.StyleType == StyleType.kstCharacter))
			{
				// send the text and props directly to the Builder, after first ensuring that
				// a ws is specified.
				int var;
				int ws = pttpProps.GetIntPropValues((int)FwTextPropType.ktptWs,
					out var);
				if (ws == -1)
				{
					ws = GetWsForContext(strbldr);
					ITsPropsBldr tpb = pttpProps.GetBldr();
					tpb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, ws);
					pttpProps = tpb.GetTextProps();
				}
				int cchLength = strbldr.Length;
				// Remove extra space.
				if (cchLength > 0 && UnicodeCharProps.get_IsSeparator(sText[0]))
				{
					string s = strbldr.GetChars(cchLength - 1, cchLength);
					if (UnicodeCharProps.get_IsSeparator(s[0]))
						sText = sText.Substring(1);
				}

				if (sText != string.Empty || cchLength == 0)
					strbldr.Replace(cchLength, cchLength, sText, pttpProps);
			}
		}
예제 #34
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine if text that belongs to ttp and vps is editable.
		/// </summary>
		/// <param name="ttp"></param>
		/// <param name="vps"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public static bool IsEditable(ITsTextProps ttp, IVwPropertyStore vps)
		{
			int nVar;
			int nVal = -1;
			if (ttp != null)
				nVal = ttp.GetIntPropValues((int)FwTextPropType.ktptEditable,
					out nVar);

			if (nVal == -1 && vps != null)
				nVal = vps.get_IntProperty((int)FwTextPropType.ktptEditable);

			if (nVal == (int)TptEditable.ktptNotEditable ||
				nVal == (int)TptEditable.ktptSemiEditable)
				return false;

			return true;
		}
예제 #35
0
		/// <summary>
		/// Compute the assembled styles that results from applying the properties specified in the text props to this.
		/// We might start with a root assembled styles that says to use a 10-point font,
		/// then apply a paragraph style which says to use a 12-point font, except for French use 14-point.
		/// Then in another text props we may tell it the writing system is French, and must get 14-point as the
		/// result. Or, in a single TsTextProps, we may tell it the WS is French and to apply a character
		/// style which says to use 16-point, except for French 18-point; the result needs to be 18-point.
		/// It's also theoretically possible that the same text props again says directly to use 20-point; that
		/// should win over all the others.
		/// We achieve most of this by simply looking for the ws, then the named style, then everything else
		/// (and when we process a style, if we already know a ws we include the overrides for that ws).
		/// However, when we process the paragraph style, we don't know what ws a run in that paragraph will have.
		/// </summary>
		/// <param name="props"></param>
		/// <returns></returns>
		public AssembledStyles ApplyTextProps(ITsTextProps props)
		{
			AssembledStyles result = this;
			// Apply writing system, if present, first, so that it can be used to select
			// a named style effect.
			int ttv;
			int ws = props.GetIntPropValues((int) FwTextPropType.ktptWs, out ttv);
			if (ttv != -1)
				result = result.WithWs(ws);
			// Apply named style next, if present, so that style effects can be overridden by explicit ones.
			var namedStyle = props.GetStrPropValue((int) FwTextPropType.ktptNamedStyle);
			if (namedStyle != null)
				result = result.WithNamedStyle(namedStyle);
			int count = props.IntPropCount;
			for (int i = 0; i < count; i++)
			{
				int tpt;
				int val = props.GetIntProp(i, out tpt, out ttv);
				switch (tpt)
				{
					case (int) FwTextPropType.ktptWs: // handled first
						break;
					case (int) FwTextPropType.ktptBold:
						int weight;

						Debug.Assert(ttv == (int) FwTextPropVar.ktpvEnum);
						switch (val)
						{
							case (int) FwTextToggleVal.kttvForceOn:
								weight = (int) VwFontWeight.kvfwBold;
								break;
								// todo JohnT: several others.
							default:
								weight = (int)VwFontWeight.kvfwNormal;
								break;
						}
						result = result.WithFontWeight(weight);
						break;
				}
			}
			return result;
		}
예제 #36
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Asserts the properties of a run are set correctly to be a hyperlink for the given
		/// URL.
		/// </summary>
		/// <param name="props">The properties.</param>
		/// <param name="expectedWs">The expected writing system.</param>
		/// <param name="sUrl">The URL.</param>
		/// ------------------------------------------------------------------------------------
		public static void VerifyHyperlinkPropsAreCorrect(ITsTextProps props, int expectedWs,
			string sUrl)
		{
			Assert.AreEqual(1, props.IntPropCount);
			int nDummy;
			Assert.AreEqual(expectedWs,
				props.GetIntPropValues((int)FwTextPropType.ktptWs, out nDummy));
			Assert.AreEqual(2, props.StrPropCount);
			Assert.AreEqual(StyleServices.Hyperlink,
				props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
			string sObjData = props.GetStrPropValue((int)FwTextPropType.ktptObjData);
			Assert.AreEqual(Convert.ToChar((int)FwObjDataTypes.kodtExternalPathName), sObjData[0]);
			Assert.AreEqual(sUrl, sObjData.Substring(1));
		}
예제 #37
0
		private void spyOnTextProps(ITsTextProps ttp)
		{
			int tpt; // ??

			// look at integer props
			int cintProps = ttp.IntPropCount;
			for (int i = 0; i < cintProps; i++)
			{
				int nVar;
				int intProp = ttp.GetIntProp(i, out tpt, out nVar);
				int Value = ttp.GetIntPropValues(tpt, out nVar);
				Value = 34; // need something so Value can be looked at
			}

			// look at string props
			int cstrProps = ttp.StrPropCount;
			for (int i = 0; i < cstrProps; i++)
			{
				string strProp = ttp.GetStrProp(i, out tpt);
				string Value = ttp.GetStrPropValue(tpt);
				Value = "why?"; // need something so Value can be looked at
			}
		}
예제 #38
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Compares two TsTextProps
		/// </summary>
		/// <param name="ttp1">expected</param>
		/// <param name="ttp2">actual</param>
		/// <param name="sHowDifferent">Human(geek)-readable string telling how the props are
		/// different, or indicating no difference</param>
		/// <returns>True if they contain the same props, false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		public static bool PropsAreEqual(ITsTextProps ttp1, ITsTextProps ttp2,
			out string sHowDifferent)
		{
			// check how intProps compare
			int cProps1 = ttp1.IntPropCount;
			int cProps2 = ttp2.IntPropCount;
			int tpv1, tpv2; // prop values
			int nVar1, nVar2; // variation info
			int tpt; // prop type
			for (int iprop = 0; iprop < cProps1; iprop++)
			{
				tpv1 = ttp1.GetIntProp(iprop, out tpt, out nVar1);
				tpv2 = ttp2.GetIntPropValues(tpt, out nVar2);

				if (tpv1 != tpv2 || nVar1 != nVar2)
				{
					if (tpt == (int)FwTextPropType.ktptWs)
						sHowDifferent = string.Format("Props differ in ktptWs property. "
							+ "Expected <{0}>, but was <{1}>.", tpv1, tpv2);
					else
						sHowDifferent = string.Format("Props differ in intProp type {0}. "
							+ "Expected <{1},{2}>, but was <{3},{4}>.", tpt, tpv1, nVar1, tpv2, nVar2);
					return false;
				}
			}
			// if count of intProps differs, it will be difficult to report exact difference
			//  so just issue a simple response for now
			if (cProps1 != cProps2)
			{
				sHowDifferent = string.Format("Props differ in count of intProps. "
					+ "Expected <{0}>, but was <{1}>.", cProps1, cProps2);
				return false;
			}

			// check for string properties differences
			int s1count = ttp1.StrPropCount;
			int s2count = ttp2.StrPropCount;
			int strtype;
			string strval1, strval2; // prop values
			for (int iprop = 0; iprop < s1count; iprop++)
			{
				strval1 = ttp1.GetStrProp(iprop, out strtype);
				strval2 = ttp2.GetStrPropValue(strtype);

				if (strval1 != strval2)
				{
					if (strtype == (int)FwTextPropType.ktptNamedStyle)
						sHowDifferent = string.Format("Props differ in ktptNamedStyle property. "
							+ "Expected <{0}>, but was <{1}>.", strval1, strval2);
					else if (strtype == (int)FwTextPropType.ktptObjData)
						sHowDifferent = string.Format("Props differ in ktptObjData property. "
							+ "Expected <{0}>, but was <{1}>.", strval1, strval2);
							// we could detail the objectDataType and Guid if needed
					else
						sHowDifferent = string.Format("Props differ in strProp type {0}. "
							+ "Expected <{1}>, but was <{2}>.", strtype, strval1, strval2);
					return false;
				}
			}
			// if count of strProps differs, it will be difficult to report exact difference
			//  so just issue a simple response for now
			if (s1count != s2count)
			{
				sHowDifferent = string.Format("Props differ in count of strProps. "
					+ "Expected <{0}>, but was <{1}>.", s1count, s2count);
				return false;
			}

			// if we reach this point, no differences were found
			sHowDifferent = "TextProps objects appear to contain the same properties.";
			return true;
		}
예제 #39
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Appends a run of text with the given TsTextProps.
		/// </summary>
		/// <param name="sRun">The text to append</param>
		/// <param name="props">The properties to use</param>
		/// ------------------------------------------------------------------------------------
		public void AppendRun(string sRun, ITsTextProps props)
		{
			CheckDisposed();
			//note: For efficiency, we usually skip the Replace() if the string is empty.
			// However, if the builder is has Length == 0, then we want to replace the
			// properties on the empty run of the TsString.
			// A TsString always has at least one run, even if it is empty, and this controls
			// the props when the user begins to enter text in an empty para.
			if (sRun != string.Empty || Length == 0)
			{
				System.Diagnostics.Debug.Assert(props != null);
				int var;
				int ws = props.GetIntPropValues((int)FwTextPropType.ktptWs, out var);

				// Make sure we handle the magic writing systems
				if (ws == (int)CellarModuleDefns.kwsAnal)
				{
					// default analysis writing system
					ITsPropsBldr bldr = props.GetBldr();
					bldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0,
						m_cache.DefaultAnalWs);
					props = bldr.GetTextProps();
				}
				else if (ws == (int)CellarModuleDefns.kwsVern)
				{
					// default vernacular writing system
					ITsPropsBldr bldr = props.GetBldr();
					bldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0,
						m_cache.DefaultVernWs);
					props = bldr.GetTextProps();
				}
				else
				{
					System.Diagnostics.Debug.Assert(ws > 0);	// not quite right if >2G objects.
				}
				m_ParaStrBldr.Replace(Length, Length, sRun, props);
			}
		}
예제 #40
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns the writing system of the specified ITsTextProps of a character style
		/// </summary>
		/// <param name="charStyleTextProps">The ITsTextProps</param>
		/// <returns>The writing system value</returns>
		/// ------------------------------------------------------------------------------------
		public static int WritingSystem(ITsTextProps charStyleTextProps)
		{
			int nVar = 0;
			return charStyleTextProps.GetIntPropValues((int)FwTextPropType.ktptWs,
				out nVar);
		}