Esempio n. 1
0
        public void TestGetStyleRgch()
        {
            IVwStylesheet stylesheet = (IVwStylesheet) new TestFwStylesheet();
            ITsPropsBldr  propsBldr  = TsPropsBldrClass.Create();

            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);
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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;
		}
Esempio n. 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This is the main interesting method of displaying objects and fragments of them.
        /// A Scripture is displayed by displaying its Books;
        /// and a Book is displayed by displaying its Title and Sections;
        /// and a Section is diplayed by displaying its Heading and Content;
        /// which are displayed by using the standard view constructor for StText.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// ------------------------------------------------------------------------------------
        public override void Display(IVwEnv vwenv, int hvo, int frag)
        {
            CheckDisposed();

            switch (frag)
            {
            case (int)FootnoteFrags.kfrScripture:
            case (int)ScrFrags.kfrScripture:
            {
                vwenv.NoteDependency(new[] { hvo }, new[] { ScrBookTags.kflidFootnotes }, 1);

                // This fragment should only be used on full refresh - clear the user prompt
                // flags so they will be shown again.
                ClearUserPromptUpdates();

                // We add this lazy - we will expand some of it immediately, but the non-
                // visible parts will remain lazy!
                vwenv.NoteDependency(new[] { m_cache.LanguageProject.TranslatedScriptureOA.Hvo },
                                     new[] { ScriptureTags.kflidScriptureBooks }, 1);
                vwenv.AddLazyVecItems(BooksTag, this,
                                      frag == (int)ScrFrags.kfrScripture ? (int)ScrFrags.kfrBook : (int)FootnoteFrags.kfrBook);

                // Add a 48 point gap at the bottom of the view
                if (!PrintLayout && (frag != (int)FootnoteFrags.kfrScripture))
                {
                    vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0);
                }
                break;
            }

            case (int)ScrFrags.kfrBook:
            {
                vwenv.OpenDiv();
                vwenv.AddObjProp(ScrBookTags.kflidTitle, this, (int)StTextFrags.kfrText);
                vwenv.AddLazyVecItems(ScrBookTags.kflidSections, this, (int)ScrFrags.kfrSection);

                // Add a 48 point gap at the bottom of the view
                if (!PrintLayout && m_fShowTailingSpace)
                {
                    vwenv.AddSimpleRect((int)ColorUtil.ConvertColorToBGR(BackColor), -1, 48000, 0);
                }

                if (!PrintLayout)
                {
                    InsertBookSeparator(hvo, vwenv);
                }
                vwenv.CloseDiv();
                break;
            }

            case (int)ScrFrags.kfrSection:
            {
                vwenv.OpenDiv();
                vwenv.AddObjProp(ScrSectionTags.kflidHeading, this, (int)StTextFrags.kfrText);
                vwenv.AddObjProp(ScrSectionTags.kflidContent, this, (int)StTextFrags.kfrText);
                vwenv.CloseDiv();
                break;
            }

            case (int)StTextFrags.kfrPara:
                if (PrintLayout || !m_fDisplayInTable)
                {
                    // We are displaying Scripture or a print layout view
                    base.Display(vwenv, hvo, frag);
                }
                else
                {
                    // We are displaying a back translation or Scripture in draftview in a table
                    // Open a table to display the BT para in column 1, and the icon in column 2.
                    VwLength vlTable;                             // we use this to specify that the table takes 100% of the width.
                    vlTable.nVal = 10000;
                    vlTable.unit = VwUnit.kunPercent100;

                    VwLength vlColumn;                             // and this one to specify 90% for the text
                    vlColumn.nVal = DisplayTranslation ? 9000 : 10000;
                    vlColumn.unit = VwUnit.kunPercent100;

                    int nColumns = DisplayTranslation ? 2 : 1;

                    vwenv.OpenTable(nColumns,                 // One or two columns.
                                    vlTable,                  // Table uses 100% of available width.
                                    0,                        // Border thickness.
                                    VwAlignment.kvaLeft,      // Default alignment.
                                    VwFramePosition.kvfpVoid, // No border.
                                                              //VwFramePosition.kvfpBox,
                                                              //VwRule.kvrlAll, // rule lines between cells
                                    VwRule.kvrlNone,
                                    0,                        //No space between cells.
                                    0,                        //No padding inside cells.
                                    false);

                    // Specify column widths. The first argument is the number of columns,
                    // not a column index.
                    vwenv.MakeColumns(nColumns, vlColumn);
                    vwenv.OpenTableBody();
                    vwenv.OpenTableRow();

                    // Display paragraph in the first cell
                    vwenv.OpenTableCell(1, 1);
                    InsertParagraphBody(vwenv, hvo, frag, true, ContentType, this);
                    vwenv.CloseTableCell();

                    if (DisplayTranslation)
                    {
                        // Stylesheet should never be null for a VC that displays BTs, but to be safe...
                        Debug.Assert(m_stylesheet != null);
                        if (m_stylesheet != null)
                        {
                            IStPara      para       = m_cache.ServiceLocator.GetInstance <IStParaRepository>().GetObject(hvo);
                            ITsTextProps styleRules = para.StyleRules;
                            if (styleRules == null)
                            {
                                Debug.Fail("Style Rules should not be null");
                                styleRules = NormalStyle;
                            }
                            string       paraStyleName = styleRules.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
                            ITsTextProps ttp           = m_stylesheet.GetStyleRgch(0, paraStyleName);
                            Debug.Assert(ttp != null);
                            if (ttp != null)
                            {
                                int var;
                                int spaceBefore = ttp.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out var);
                                if (spaceBefore > 0)
                                {
                                    vwenv.set_IntProperty((int)FwTextPropType.ktptPadTop, var, spaceBefore);
                                }
                            }
                        }
                        // BT status icon in the next cell, not editable
                        vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
                                              (int)TptEditable.ktptNotEditable);
                        vwenv.OpenTableCell(1, 1);
                        vwenv.AddObjVec(StTxtParaTags.kflidTranslations, this, (int)ScrFrags.kfrBtTranslationStatus);
                        vwenv.CloseTableCell();
                    }

                    // Close table
                    vwenv.CloseTableRow();
                    vwenv.CloseTableBody();
                    vwenv.CloseTable();
                }
                break;

            case (int)ScrFrags.kfrBtTranslationStatus:
            {
                ICmTranslation trans = m_cache.ServiceLocator.GetInstance <ICmTranslationRepository>().GetObject(hvo);
                if (trans != null)
                {
                    string   status = trans.Status.get_String(m_wsDefault).Text;
                    IPicture picture;
                    if (status == BackTranslationStatus.Checked.ToString())
                    {
                        picture = m_CheckedPic;
                    }
                    else if (status == BackTranslationStatus.Finished.ToString())
                    {
                        picture = m_FinishedPic;
                    }
                    else
                    {
                        picture = m_UnfinishedPic;
                    }

                    vwenv.OpenDiv();
                    vwenv.AddPicture(picture, -1, 0, 0);
                    vwenv.NoteDependency(new [] { hvo }, new [] { CmTranslationTags.kflidStatus }, 1);
                    vwenv.CloseDiv();
                }
            }
            break;

            default:
                base.Display(vwenv, hvo, frag);
                break;
            }
        }
Esempio n. 5
0
        public void CorrectionPrintoutLineSpacing()
        {
            // Set up a ScripturePublication with no scaling specified.
            m_pub.BaseFontSize    = 12000;
            m_pub.BaseLineSpacing = -36000;
            DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                TeViewType.Correction, 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(12000,
                            ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            Assert.AreEqual(-36000,
                            ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            scrPub.Dispose();

            // 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));
        }
Esempio n. 6
0
		private void ReadStyles(IVwStylesheet vss)
		{
			string normalStyleName = vss.GetDefaultBasedOnStyleName();
			m_styleTable = new StyleInfoTable(normalStyleName,
				m_cache.ServiceLocator.WritingSystemManager);
			int cStyles = vss.CStyles;
			for (int i = 0; i < cStyles; ++i)
			{
				int hvo = vss.get_NthStyle(i);
				var sty = m_cache.ServiceLocator.GetInstance<IStStyleRepository>().GetObject(hvo);
				// CSS does not implement the kind of inheritance our styles use. To get the style
				// definitions we want in the CSS, we must create these styles using the 'net effect' of
				// each style and all the ones it is based on. Happily the VwStyleSheet knows exactly
				// how to do this.
				var props = vss.GetStyleRgch(sty.Name.Length, sty.Name);
				var exportStyleInfo = new ExportStyleInfo(sty, props);
				m_styleTable.Add(GetValidCssClassName(sty.Name), exportStyleInfo);
			}
		}
Esempio n. 7
0
        public void HugeTextScaling()
        {
            // Set up a ScripturePublication of 4 on 6 pts (base character size on line spacing).
            m_pub.BaseFontSize    = 120000;
            m_pub.BaseLineSpacing = -120020;
            DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                TeViewType.Scripture | TeViewType.PrintLayout, m_realStylesheet);
            IVwStylesheet stylesheet    = scrPub.StyleSheet;
            ITsTextProps  ttpNormalPara = scrPub.StyleSheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
            int           nVar;

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

            // We expect that these styles will be overridden for font size at 1200% their original size
            // (except where they would go above the maximum size).
            ITsTextProps styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.IntroParagraph);

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

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

            // We expect that these styles will be overridden for space before/after at 1000.1667% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(360060, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(120020, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(80013, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(40007, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
Esempio n. 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;
            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(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));
        }
Esempio n. 9
0
        public void DefaultTextScaling_OneColFullPgLetterPaper()
        {
            m_pub.Name                      = "Scripture Draft";
            m_pub.BaseFontSize              = 0;
            m_pub.BaseLineSpacing           = 0;
            m_pub.PaperHeight               = (int)(11 * 72000);
            m_pub.PaperWidth                = (int)(8.5 * 72000);
            m_pub.PageHeight                = 0;
            m_pub.PageWidth                 = 0;
            m_pub.DivisionsOS[0].NumColumns = 1;
            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 be unchanged.
            Assert.AreEqual(10000,
                            ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptFontSize, out nVar));
            Assert.AreEqual(-12000,
                            ttpNormalPara.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out nVar));
            scrPub.Dispose();

            // 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));
        }
Esempio n. 10
0
        public void DefaultTextScalingForOneColumnTrialPub()
        {
            // Set up a ScripturePublication with no scaling specified, but which looks like
            // a Trial Publication.
            m_pub.Name                      = "Trial Publication";
            m_pub.BaseFontSize              = 0;
            m_pub.BaseLineSpacing           = 0;
            m_pub.PageHeight                = (int)(8.7 * 72000);
            m_pub.PageWidth                 = (int)(5.8 * 72000);
            m_pub.DivisionsOS[0].NumColumns = 1;
            DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                TeViewType.Scripture | TeViewType.TrialPublication, m_realStylesheet);
            IVwStylesheet stylesheet    = scrPub.StyleSheet;
            ITsTextProps  ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
            int           nVar;

            // 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));
            scrPub.Dispose();

            // 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));
        }
Esempio n. 11
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));
        }