示例#1
0
        public void PropsDifferByCount()
        {
            // test of different string property counts
            ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();

            //note: due to design in PropsAreEqual(), we will get the count message
            // only when all the str props in the first ttp match in the second ttp, and the
            // second ttp has additional str props
            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptFontFamily,
                                        "my font");
            ITsTextProps ttp1 = tsPropsBldr.GetTextProps();

            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "my style");
            ITsTextProps ttp2 = tsPropsBldr.GetTextProps();
            string       s;

            Assert.IsFalse(TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out s));
            Assert.AreEqual("Props differ in count of strProps. Expected <1>, but was <2>.", s);

            // test of different int property counts
            tsPropsBldr = TsPropsBldrClass.Create();             // empty builder
            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptBorderColor,
                                         (int)FwTextPropVar.ktpvDefault, 123);
            ttp1 = tsPropsBldr.GetTextProps();
            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptBorderTop,
                                         (int)FwTextPropVar.ktpvDefault, 10);
            ttp2 = tsPropsBldr.GetTextProps();
            Assert.IsFalse(TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out s));
            Assert.AreEqual("Props differ in count of intProps. Expected <1>, but was <2>.", s);
        }
示例#2
0
        public void TsStringsTwoEmpty_IntPropsDiffer()
        {
            CheckDisposed();
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 45);
            ITsTextProps propsS1 = propsBldr.GetTextProps();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 15);
            ITsTextProps propsS2 = propsBldr.GetTextProps();

            // Create TsString #1
            strBldr.Replace(0, 0, "", propsS1);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2
            strBldr = TsStrBldrClass.Create();
            strBldr.Replace(0, 0, "", propsS2);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings differ in format of run 1.\n\t" +
                "Props differ in ktptWs property. Expected <45>, but was <15>.",
                s, "Got incorrect explanation of difference");
        }
示例#3
0
        public void PropsDifferByIntProps()
        {
            // test of different int prop: writing system
            ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();

            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                         (int)FwTextPropVar.ktpvDefault, 4565754);
            ITsTextProps ttp1 = tsPropsBldr.GetTextProps();

            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                         (int)FwTextPropVar.ktpvDefault, 4565753);
            ITsTextProps ttp2 = tsPropsBldr.GetTextProps();
            string       s;

            Assert.IsFalse(TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out s));
            Assert.AreEqual("Props differ in ktptWs property. Expected ws <4565754> and var <0>, but was ws <4565753> and var <0>.", s);

            // test of different int prop: background color
            tsPropsBldr = TsPropsBldrClass.Create(); // empty builder
            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                        "my style"); //string prop, same for both
            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptBackColor,
                                         (int)FwTextPropVar.ktpvDefault, 98);
            ttp1 = tsPropsBldr.GetTextProps();
            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptBackColor,
                                         (int)FwTextPropVar.ktpvDefault, 99);
            ttp2 = tsPropsBldr.GetTextProps();
            Assert.IsFalse(TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out s));
            Assert.AreEqual("Props differ in intProp type 9. "
                            + "Expected <98,0>, but was <99,0>.", s);
        }
示例#4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates the expected user prompt string
        /// </summary>
        /// <param name="text">text for the prompt</param>
        /// <param name="ws">writing system to use for the ZWS character</param>
        /// ------------------------------------------------------------------------------------
        private ITsString ExpectedUserPrompt(string text, int ws)
        {
            // Set up the text we expect to be added to the paragraph
            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();

            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptBackColor,
                                     (int)FwTextPropVar.ktpvDefault,
                                     (int)ColorUtil.ConvertColorToBGR(Color.LightGray));
            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, Cache.WritingSystemFactory.UserWs);
            ttpBldr.SetIntPropValues(SimpleRootSite.ktptUserPrompt,
                                     (int)FwTextPropVar.ktpvDefault, 1);
            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptSpellCheck,
                                     (int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck);
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            strBldr.Replace(0, 0, text, ttpBldr.GetTextProps());

            ITsPropsBldr ttpBldr2 = TsPropsBldrClass.Create();

            ttpBldr2.SetIntPropValues((int)FwTextPropType.ktptWs,
                                      (int)FwTextPropVar.ktpvDefault, ws);
            ttpBldr2.SetIntPropValues(SimpleRootSite.ktptUserPrompt,
                                      (int)FwTextPropVar.ktpvDefault, 1);
            strBldr.Replace(0, 0, "\u200B", ttpBldr2.GetTextProps());

            return(strBldr.GetString());
        }
示例#5
0
//		/// ------------------------------------------------------------------------------------
//		/// <summary>
//		/// Builds a number string for the preview window based on the settings in the
//		/// Number group and the selected numbering scheme
//		/// </summary>
//		/// <param name="line">The line.</param>
//		/// ------------------------------------------------------------------------------------
//		private string GetNumberString(int line)
//		{
//			return GetNumberString(line, m_nudStartAt.Value, m_cboNumberScheme.SelectedIndex,
//				m_tbTextBefore.Text, m_tbTextAfter.Text);
//		}

//		/// ------------------------------------------------------------------------------------
//		/// <summary>
//		/// Builds a number string for the preview window based on the given values
//		/// </summary>
//		/// <param name="line">The line.</param>
//		/// <param name="nStartAt">The number to start at.</param>
//		/// <param name="iScheme">The i scheme.</param>
//		/// <param name="textBefore">The text before.</param>
//		/// <param name="textAfter">The text after.</param>
//		/// <returns></returns>
//		/// ------------------------------------------------------------------------------------
//		private string GetNumberString(int line, int nStartAt, int iScheme, string textBefore,
//			string textAfter)
//		{
//			int number = nStartAt + line;
//			string numberString = string.Empty;
//			switch (iScheme)
//			{
//				case 0:		// 1, 2, 3'
//					numberString = number.ToString();
//					break;

//				case 1:		// I, II, III (Roman numerals)
//					numberString = RomanNumerals.IntToRoman(number);
//					break;

//				case 2:		// i, ii, iii (lower case Roman numerals)
//					numberString = RomanNumerals.IntToRoman(number).ToLowerInvariant();
//					break;

//				case 3:		// A, B, C
//					numberString = AlphaOutline.NumToAlphaOutline(number);
//					break;

//				case 4:		// a, b, c
//					numberString = AlphaOutline.NumToAlphaOutline(number).ToLowerInvariant();
//					break;

//				case 5:		// 01, 02, 03
//					numberString = number.ToString("d2");
//					break;
//			}

//			return textBefore + numberString + textAfter;
//		}

        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// When any data field changes, refresh the preview panel
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void DataChange(object sender, EventArgs e)
        {
            // If the value in the "start at" spinner control is other than 1, then check
            // the start at check box
            if (m_nudStartAt.Value != 1)
            {
                m_chkStartAt.Checked = true;
            }

            UpdateBulletInfo(ref m_currentStyleBulletInfo);
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            m_currentStyleBulletInfo.ConvertAsTextProps(propsBldr);
            propsBldr.SetIntPropValues((int)FwTextPropType.ktptSpaceBefore,
                                       (int)FwTextPropVar.ktpvMilliPoint, 6000);
            ITsTextProps propsFirst = propsBldr.GetTextProps();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptBulNumStartAt, -1, -1);

            m_preview.SetProps(propsFirst, propsBldr.GetTextProps());
            m_preview.Refresh();

            if (StyleDataChanged != null)
            {
                StyleDataChanged(this, null);
            }
        }
示例#6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fdoCache"></param>
        /// <returns></returns>
        public static ITsTextProps PartOfSpeechTextProperties(LcmCache fdoCache, bool inAnalysisLine, bool fUseStyleSheet)
        {
            int          color = (int)CmObjectUi.RGB(Color.Green);
            ITsPropsBldr bldr  = TsStringUtils.MakePropsBldr();

            if (!fUseStyleSheet)
            {
                bldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                      (int)FwTextPropVar.ktpvMilliPoint, (int)(s_baseFontSize * 1000 * .8));
            }
            bldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, fdoCache.DefaultAnalWs);
            //			bldr.SetIntPropValues((int)FwTextPropType.ktptItalic,
            //				(int)FwTextPropVar.ktpvEnum,
            //				(int)FwTextToggleVal.kttvInvert);

            if (inAnalysisLine)
            {
                bldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
                                      (int)FwTextPropVar.ktpvEnum,
                                      (int)FwSuperscriptVal.kssvSub);
            }



            bldr.SetIntPropValues((int)FwTextPropType.ktptForeColor,
                                  (int)FwTextPropVar.ktpvDefault, color);
            return(bldr.GetTextProps());
        }
示例#7
0
        /// <summary>
        /// We only use this to generate our empty text prompt.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="tag"></param>
        /// <param name="v"></param>
        /// <param name="frag"></param>
        /// <returns></returns>
        public override ITsString DisplayVariant(IVwEnv vwenv, int tag, object v, int frag)
        {
            CheckDisposed();

            string userPrompt = ITextStrings.ksEnterOrPasteHere;

            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();

            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptBackColor,
                                     (int)FwTextPropVar.ktpvDefault, Color.LightGray.ToArgb());
            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                     (int)FwTextPropVar.ktpvDefault, Cache.DefaultUserWs);
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, userPrompt, ttpBldr.GetTextProps());
            // Begin the prompt with a zero-width space in the vernacular writing system (with
            // no funny colors).  This ensures anything the user types (or pastes from a non-FW
            // clipboard) is put in that WS.
            // 200B == zero-width space.
            ITsPropsBldr ttpBldr2 = TsPropsBldrClass.Create();

            ttpBldr2.SetIntPropValues((int)FwTextPropType.ktptWs,
                                      (int)FwTextPropVar.ktpvDefault, Cache.DefaultVernWs);
            bldr.Replace(0, 0, "\u200B", ttpBldr2.GetTextProps());
            return(bldr.GetString());
        }
        public void TsStringsTwoEmpty_ExpectedIntProp()
        {
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 45);
            ITsTextProps propsS2 = propsBldr.GetTextProps();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript, (int)FwTextPropVar.ktpvEnum, 1);
            ITsTextProps propsS1 = propsBldr.GetTextProps();

            // Create TsString #1
            strBldr.Replace(0, 0, "", propsS1);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2
            strBldr = TsStrBldrClass.Create();
            strBldr.Replace(0, 0, "", propsS2);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings differ in format of run 1." + Environment.NewLine +
                "\tProps differ in intProp type " + (int)FwTextPropType.ktptSuperscript + ". Expected <1,3>, but was <-1,-1>.",
                s, "Got incorrect explanation of difference");
        }
        public void TsStringsTwoEmpty_WritingSystemsDiffer()
        {
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 45);
            ITsTextProps propsS1 = propsBldr.GetTextProps();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 15);
            ITsTextProps propsS2 = propsBldr.GetTextProps();

            // Create TsString #1
            strBldr.Replace(0, 0, "", propsS1);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2
            strBldr = TsStrBldrClass.Create();
            strBldr.Replace(0, 0, "", propsS2);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings differ in format of run 1." + Environment.NewLine +
                "\tProps differ in ktptWs property. Expected ws <45> and var <0>, but was ws <15> and var <0>.",
                s, "Got incorrect explanation of difference");
        }
示例#10
0
 private static void ApplyStyleToTsPropertyBuilder(ITsPropsBldr tpb, string style)
 {
     if (String.IsNullOrEmpty(style))
     {
         return;
     }
     style = style.ToLowerInvariant();
     // N.B.: Was tempted to refactor with IndexOf("-"), but realized
     // that style could be "italic -bold" or "-italic bold" or "-italic -bold".
     if (style.IndexOf("-bold") >= 0)
     {
         tpb.SetIntPropValues((int)FwTextPropType.ktptBold,
                              (int)FwTextPropVar.ktpvEnum,
                              (int)FwTextToggleVal.kttvOff);
     }
     else if (style.IndexOf("bold") >= 0)
     {
         tpb.SetIntPropValues((int)FwTextPropType.ktptBold,
                              (int)FwTextPropVar.ktpvEnum,
                              (int)FwTextToggleVal.kttvForceOn);
     }
     if (style.IndexOf("-italic") >= 0)
     {
         tpb.SetIntPropValues((int)FwTextPropType.ktptItalic,
                              (int)FwTextPropVar.ktpvEnum,
                              (int)FwTextToggleVal.kttvOff);
     }
     else if (style.IndexOf("italic") >= 0)
     {
         tpb.SetIntPropValues((int)FwTextPropType.ktptItalic,
                              (int)FwTextPropVar.ktpvEnum,
                              (int)FwTextToggleVal.kttvForceOn);
     }
 }
示例#11
0
        public RuleFormulaVc(FdoCache cache, XCore.Mediator mediator)
        {
            m_cache    = cache;
            m_mediator = mediator;

            // use Doulos SIL because it supports the special characters that are needed for
            // multiline brackets
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Charis SIL");
            m_bracketProps = tpb.GetTextProps();

            tpb = TsPropsBldrClass.Create();
            tpb.SetIntPropValues((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
            tpb.SetIntPropValues((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN);
            m_pileProps = tpb.GetTextProps();

            m_empty               = m_cache.MakeUserTss("");
            m_infinity            = m_cache.MakeUserTss("\u221e");
            m_leftBracketUpHook   = m_cache.MakeUserTss("\u23a1");
            m_leftBracketExt      = m_cache.MakeUserTss("\u23a2");
            m_leftBracketLowHook  = m_cache.MakeUserTss("\u23a3");
            m_rightBracketUpHook  = m_cache.MakeUserTss("\u23a4");
            m_rightBracketExt     = m_cache.MakeUserTss("\u23a5");
            m_rightBracketLowHook = m_cache.MakeUserTss("\u23a6");
            m_leftBracket         = m_cache.MakeUserTss("[");
            m_rightBracket        = m_cache.MakeUserTss("]");
            m_questions           = m_cache.MakeUserTss("???");
            m_leftParen           = m_cache.MakeUserTss("(");
            m_rightParen          = m_cache.MakeUserTss(")");
            m_x       = m_cache.MakeUserTss("X");
            m_zwSpace = m_cache.MakeUserTss("\u200b");
        }
示例#12
0
        public RegRuleFormulaVc(FdoCache cache, XCore.Mediator mediator)
            : base(cache, mediator)
        {
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
            m_ctxtProps = tpb.GetTextProps();

            tpb = TsPropsBldrClass.Create();
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 20000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Arial");
            tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            m_charProps = tpb.GetTextProps();

            m_arrow      = m_cache.MakeUserTss("\u2192");
            m_slash      = m_cache.MakeUserTss("/");
            m_underscore = m_cache.MakeUserTss("__");
        }
示例#13
0
        public RegRuleFormulaVc(FdoCache cache, Mediator mediator)
            : base(cache, mediator)
        {
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
            m_ctxtProps = tpb.GetTextProps();

            tpb = TsPropsBldrClass.Create();
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 20000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadLeading, (int)FwTextPropVar.ktpvMilliPoint, 2000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTrailing, (int)FwTextPropVar.ktpvMilliPoint, 2000);
            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, MiscUtils.StandardSansSerif);
            tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            m_charProps = tpb.GetTextProps();

            ITsStrFactory tsf    = m_cache.TsStrFactory;
            int           userWs = m_cache.DefaultUserWs;

            m_arrow      = tsf.MakeString("\u2192", userWs);
            m_slash      = tsf.MakeString("/", userWs);
            m_underscore = tsf.MakeString("__", userWs);
        }
示例#14
0
        public SimpleStyleSheet()
        {
            ITsPropsBldr tpb = (ITsPropsBldr) new FwKernelLib.TsPropsBldrClass();

            m_ttpNormal = tpb.GetTextProps();             // normal has nothing defined, use system defaults.
            tpb.SetIntPropValues((int)FwKernelLib.FwTextPropType.ktptForeColor, (int)FwKernelLib.FwTextPropVar.ktpvDefault,
                                 (int)ViewSampleVc.RGB(Color.Red));
            tpb.SetIntPropValues((int)FwKernelLib.FwTextPropType.ktptSuperscript, (int)FwKernelLib.FwTextPropVar.ktpvEnum,
                                 (int)FwKernelLib.FwSuperscriptVal.kssvSuper);
            m_ttpVerseNumber = tpb.GetTextProps();
        }
        protected ITsString MakeSimpleString(String str)
        {
            ITsStrBldr   builder = TsStrBldrClass.Create();
            ITsPropsBldr bldr    = TsPropsBldrClass.Create();

            bldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_cache.DefaultUserWs);
            bldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                  (int)FwTextPropVar.ktpvMilliPoint, s_baseFontSize * 800);
            bldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, "Arial");
            builder.Replace(0, 0, str, bldr.GetTextProps());
            return(builder.GetString());
        }
示例#16
0
        protected ITsString MakeSimpleString(String str)
        {
            ITsStrBldr   builder = TsStringUtils.MakeStrBldr();
            ITsPropsBldr bldr    = TsStringUtils.MakePropsBldr();

            bldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_cache.DefaultUserWs);
            bldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                  (int)FwTextPropVar.ktpvMilliPoint, s_baseFontSize * 800);
            bldr.SetStrPropValue((int)FwTextStringProp.kstpFontFamily, MiscUtils.StandardSansSerif);
            builder.Replace(0, 0, str, bldr.GetTextProps());
            return(builder.GetString());
        }
示例#17
0
        public void ExportPicture_MultipleWS()
        {
            // Create a picture that has a caption with three different writing systems.
            ITsStrBldr   tssBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, InMemoryFdoCache.s_wsHvos.De);
            tssBldr.ReplaceRgch(0, 0, "photo", 5, propsBldr.GetTextProps());
            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, InMemoryFdoCache.s_wsHvos.Ur);
            tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " tasvir", 7, propsBldr.GetTextProps());
            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, Cache.DefaultVernWs);
            tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " picture caption", 16, propsBldr.GetTextProps());
            CmPicture picture = new CmPicture(m_inMemoryCache.Cache, @"c:\filename.jpg", tssBldr.GetString(), "folder");

            // Set up for export
            StringWriter  stream = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(stream);

            writer.Formatting = Formatting.None;
            m_exporter        = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
                                              "ExportPicture_MultipleWS");
            ReflectionHelper.SetField(m_exporter, "m_writer", writer);

            // Export the picture to XML
            ReflectionHelper.CallMethod(m_exporter, "ExportPicture", picture);

            // Check the results of the exported picture.
            //   Set up expected results.
            string defaultDir = DirectoryFinder.FWDataDirectory;
            // TODO (TE-7756): Support OXES export and import of new properties that have been
            // added to the CmPicture model
            string strExpected = "<figure src=\"filename.jpg\"><!--path=\"" + defaultDir + "\\filename\"-->" +
                                 "<caption><trGroup><tr><foreign xml:lang=\"de\">photo</foreign>" +
                                 "<foreign xml:lang=\"ur\"> tasvir</foreign> picture caption</tr></trGroup></caption></figure>";
            XmlDocument expected = new XmlDocument();

            expected.Load(new StringReader(strExpected));

            //   Get actual results.
            XmlDocument actual = new XmlDocument();

            actual.Load(new StringReader(stream.ToString()));

            string strDifference;

            if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
            {
                Assert.Fail(strDifference);
            }
        }
示例#18
0
        /// <summary>
        /// Return an ITsTextProps typically used for WS labels in views.
        /// </summary>
        public static ITsTextProps LanguageCodeTextProps(int wsUser)
        {
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            tpb.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault,
                                 wsUser);
            tpb.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                 BGR(47, 96, 255));
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint,
                                 8000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
                                 (int)TptEditable.ktptNotEditable);
            tpb.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, StyleServices.UiElementStylename);
            return(tpb.GetTextProps());
        }
示例#19
0
        public void CreateFromStringRep_BT_withBrackets()
        {
            SetupBackTrans();

            // Setup expected results for the footnote
            ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                       (int)FwTextPropVar.ktpvDefault, m_vernWs);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
            ITsStrBldr bldr = TsStringUtils.MakeStrBldr();

            bldr.Replace(0, 0, "Text in <brackets>", propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      null);
            m_footnotePara.Contents = bldr.GetString();

            // ... and now set up the expected results for the back translations of the footnote.
            AddRunToMockedTrans(m_trans, m_wsEs, "Spanish BT in <brackets>", null);
            AddRunToMockedTrans(m_trans, m_wsDe, "German BT in <brackets>", null);

            // Define text representation and create a footnote from it.
            string footnoteRep = @"<FN><M>o</M><P><PS>Note General Paragraph</PS>" +
                                 @"<RUN WS='fr'>Text in &lt;brackets&gt;</RUN>" +
                                 @"<TRANS WS='de'><RUN WS='de'>German BT in &lt;brackets&gt;</RUN></TRANS>" +
                                 @"<TRANS WS='es'><RUN WS='es'>Spanish BT in &lt;brackets&gt;</RUN></TRANS></P></FN>";
            IStFootnote footnote = Cache.ServiceLocator.GetInstance <IScrFootnoteFactory>().CreateFromStringRep(m_book,
                                                                                                                footnoteRep, 0, "Note Marker");

            CompareFootnote(footnote);
        }
示例#20
0
 int GetIterCtxtWidth(IPhIterationContext ctxt, IVwEnv vwenv)
 {
     if (ctxt.MemberRAHvo != 0)
     {
         int len      = GetSimpleCtxtWidth(ctxt.MemberRA as IPhSimpleContext, vwenv);
         int numLines = GetNumLines(ctxt.MemberRA);
         if (numLines > 1)
         {
             len += GetMinMaxWidth(ctxt, null, vwenv);
         }
         else
         {
             if (ctxt.MemberRA.ClassID != PhSimpleContextNC.kclsidPhSimpleContextNC)
             {
                 len += GetStrWidth(m_leftParen, null, vwenv);
                 len += GetStrWidth(m_rightParen, null, vwenv);
             }
             int          fontHeight     = GetFontHeight(m_cache.DefaultUserWs);
             int          superSubHeight = (fontHeight * 2) / 3;
             ITsPropsBldr tpb            = TsPropsBldrClass.Create();
             tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, superSubHeight);
             len += GetMinMaxWidth(ctxt, tpb.GetTextProps(), vwenv);
         }
         return(len);
     }
     else
     {
         return(GetStrWidth(m_questions, null, vwenv));
     }
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Init writing system info and some props needed by some tests.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected void InitWsInfo()
        {
            Debug.Assert(Cache != null);

            // get writing system info needed by tests
            m_wsVern = Cache.DefaultVernWs;
            m_wsAnal = Cache.DefaultAnalWs;

            // init simple run text props expected by tests
            ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();

            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsVern);
            m_ttpVernWS = tsPropsBldr.GetTextProps();
            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, m_wsAnal);
            m_ttpAnalWS = tsPropsBldr.GetTextProps();
        }
示例#22
0
        /// <summary>
        /// Gets the character render properties for the given style name and writing system.
        /// </summary>
        /// <param name="styleName">The style name.</param>
        /// <param name="styleSheet">The stylesheet.</param>
        /// <param name="hvoWs">The HVO of the WS.</param>
        /// <param name="writingSystemFactory">The writing system factory.</param>
        /// <returns>The character render properties.</returns>
        public static LgCharRenderProps GetChrpForStyle(string styleName, IVwStylesheet styleSheet,
                                                        int hvoWs, ILgWritingSystemFactory writingSystemFactory)
        {
            if (string.IsNullOrEmpty(writingSystemFactory.GetStrFromWs(hvoWs)))
            {
                try
                {
                    throw new ArgumentException("This is a hard-to-reproduce scenario (TE-6891) where writing system (" + hvoWs + ") and factory are inconsistent. Call an expert (JohnT)");
                }
                catch (ArgumentException e)
                {
                    Logger.WriteError(e);
                    Debug.Fail("This is a hard-to-reproduce scenario (TE-6891) where writing system and factory are inconsistent. Call an expert (JohnT) while you have this Assert active!");
                    hvoWs = writingSystemFactory.UserWs;
                }
            }

            IVwPropertyStore vwps = VwPropertyStoreClass.Create();

            vwps.Stylesheet           = styleSheet;
            vwps.WritingSystemFactory = writingSystemFactory;

            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();

            ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, styleName);
            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, hvoWs);
            ITsTextProps ttp = ttpBldr.GetTextProps();

            LgCharRenderProps chrps = vwps.get_ChrpFor(ttp);
            IWritingSystem    ws    = writingSystemFactory.get_EngineOrNull(hvoWs);

            ws.InterpretChrp(ref chrps);
            return(chrps);
        }
示例#23
0
        public void PropsDifferByStrProps()
        {
            // test of different str prop: named style
            ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();

            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                        "my style");
            ITsTextProps ttp1 = tsPropsBldr.GetTextProps();

            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                        "your style");
            ITsTextProps ttp2 = tsPropsBldr.GetTextProps();
            string       s;

            Assert.IsFalse(TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out s));
            Assert.AreEqual("Props differ in ktptNamedStyle property. "
                            + "Expected <my style>, but was <your style>.", s);

            // test of different str prop: named style
            tsPropsBldr = TsPropsBldrClass.Create();                               // empty builder
            tsPropsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                         (int)FwTextPropVar.ktpvDefault, 4565754); // int prop, same for both
            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptFontFamily,
                                        "my font");
            ttp1 = tsPropsBldr.GetTextProps();
            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptFontFamily,
                                        "your font");
            ttp2 = tsPropsBldr.GetTextProps();
            Assert.IsFalse(TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out s));
            Assert.AreEqual("Props differ in strProp type 1. "
                            + "Expected <my font>, but was <your font>.", s);
        }
示例#24
0
        public void CreateFromStringRep_BT_withBrackets()
        {
            CheckDisposed();
            SetupBackTrans();

            // Setup expected results for the footnote
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                       (int)FwTextPropVar.ktpvDefault, m_vernWs);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, null);
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Text in <brackets>", propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      null);
            m_footnotePara.Contents.UnderlyingTsString = bldr.GetString();

            // ... and now set up the expected results for the back translations of the footnote.
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsEs, "Spanish BT in <brackets>", null);
            m_scrInMemoryCache.AddRunToMockedTrans(m_trans, m_wsDe, "German BT in <brackets>", null);

            // Define text representation and create a footnote from it.
            string footnoteRep = @"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                                 @"<RUN WS='fr'>Text in &lt;brackets&gt;</RUN>" +
                                 @"<TRANS WS='es'><RUN WS='es'>Spanish BT in &lt;brackets&gt;</RUN></TRANS>" +
                                 @"<TRANS WS='de'><RUN WS='de'>German BT in &lt;brackets&gt;</RUN></TRANS></P></FN>";
            StFootnote footnote = StFootnote.CreateFromStringRep(m_book,
                                                                 (int)ScrBook.ScrBookTags.kflidFootnotes, footnoteRep, 0, "Note Marker");

            CompareFootnote(footnote);
        }
示例#25
0
        public void CreateFromStringRep_twoCharStylePara()
        {
            ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                       (int)FwTextPropVar.ktpvDefault,
                                       m_vernWs);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      "Emphasis");
            ITsStrBldr bldr = TsStringUtils.MakeStrBldr();

            bldr.Replace(0, 0, "Test Text", propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      null);
            bldr.Replace(bldr.Length, bldr.Length, "No char style",
                         propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      "Quoted Text");
            bldr.Replace(bldr.Length, bldr.Length, "Ahh!!!!!!",
                         propsBldr.GetTextProps());
            m_footnotePara.Contents = bldr.GetString();

            string footnoteRep = @"<FN><M>o</M><P><PS>Note General Paragraph</PS>" +
                                 @"<RUN WS='fr' CS='Emphasis'>Test Text</RUN><RUN WS='fr'>No char style</RUN>" +
                                 "<RUN WS='fr' CS='Quoted Text'>Ahh!!!!!!</RUN></P></FN>";
            IStFootnote footnote = Cache.ServiceLocator.GetInstance <IScrFootnoteFactory>().CreateFromStringRep(m_book,
                                                                                                                footnoteRep, 0, "Note Marker");

            CompareFootnote(footnote);
        }
示例#26
0
        private static TsTextProps EditIntProperty(TsTextProps textProps, int tpt, int nVar, int nVal)
        {
            ITsPropsBldr tpb = textProps.GetBldr();

            tpb.SetIntPropValues(tpt, nVar, nVal);
            return((TsTextProps)tpb.GetTextProps());
        }
示例#27
0
        public void CreateFromStringRep_twoCharStylePara()
        {
            CheckDisposed();

            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs,
                                       (int)FwTextPropVar.ktpvDefault,
                                       m_vernWs);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      "Emphasis");
            ITsStrBldr bldr = TsStrBldrClass.Create();

            bldr.Replace(0, 0, "Test Text", propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      null);
            bldr.Replace(bldr.Length, bldr.Length, "No char style",
                         propsBldr.GetTextProps());
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                      "Quoted Text");
            bldr.Replace(bldr.Length, bldr.Length, "Ahh!!!!!!",
                         propsBldr.GetTextProps());
            m_footnotePara.Contents.UnderlyingTsString = bldr.GetString();

            string footnoteRep = @"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
                                 @"<RUN WS='fr' CS='Emphasis'>Test Text</RUN><RUN WS='fr'>No char style</RUN>" +
                                 "<RUN WS='fr' CS='Quoted Text'>Ahh!!!!!!</RUN></P></FN>";
            StFootnote footnote = StFootnote.CreateFromStringRep(m_book,
                                                                 (int)ScrBook.ScrBookTags.kflidFootnotes, footnoteRep, 0, "Note Marker");

            CompareFootnote(footnote);
        }
示例#28
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);
        }
示例#29
0
        public void TsStringsDifferByRunBreaks()
        {
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 1);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "S1");
            ITsTextProps propsS1 = propsBldr.GetTextProps();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "S2");
            ITsTextProps propsS2 = propsBldr.GetTextProps();

            // Create TsString #1: "Weird/Test/Dude"
            strBldr.Replace(0, 0, "Dude", propsS1);
            strBldr.Replace(0, 0, "Test", propsS2);
            strBldr.Replace(0, 0, "Weird", propsS1);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2: "Weird/Tes/tDude"
            strBldr = TsStrBldrClass.Create();
            strBldr.Replace(0, 0, "tDude", propsS1);
            strBldr.Replace(0, 0, "Tes", propsS2);
            strBldr.Replace(0, 0, "Weird", propsS1);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                string.Format("TsStrings differ in length of run 2.{0}\tExpected length=4, but was length=3.{0}\t" +
                              "expected run:<Test>{0}\t" +
                              "     but was:<Tes>", Environment.NewLine), s,
                "Got incorrect explanation of difference");
        }
示例#30
0
        public void TestTsStringWrapperRoundTrip(string str1, string namedStyle1, string str2, string namedStyle2)
        {
            var          wsFact  = new PalasoWritingSystemManager();
            ITsStrBldr   bldr    = TsStrBldrClass.Create();
            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();

            try
            {
                wsFact.get_Engine("en");
                ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsFact.GetWsFromStr("en"));
                ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, namedStyle1);
                bldr.Replace(bldr.Length, bldr.Length, str1, ttpBldr.GetTextProps());
                if (namedStyle2 != null && str2 != null)
                {
                    ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, namedStyle2);
                    bldr.Replace(bldr.Length, bldr.Length, str2, ttpBldr.GetTextProps());
                }
                var tsString1 = bldr.GetString();

                var strWrapper = new TsStringWrapper(tsString1, wsFact);

                var tsString2 = strWrapper.GetTsString(wsFact);

                Assert.AreEqual(tsString1.Text, tsString2.Text);
            }
            finally
            {
                Marshal.ReleaseComObject(ttpBldr);
                Marshal.ReleaseComObject(bldr);
            }
        }
示例#31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Read the paragraph properties from the XML node and set the properties in the given
		/// props builder.
		/// </summary>
		/// <param name="styleName">Name of style being created/updated (for error reporting)
		/// </param>
		/// <param name="styleTag">XML node that has the paragraph properties</param>
		/// <param name="propsBldr">the props builder to store the props</param>
		/// ------------------------------------------------------------------------------------
		protected void SetParagraphProperties(string styleName, XmlNode styleTag,
			ITsPropsBldr propsBldr)
		{
			XmlNode node = styleTag.SelectSingleNode("paragraph");
			if (node == null)
			{
				ReportInvalidInstallation(String.Format(
					FrameworkStrings.ksMissingParagraphNode, styleName, ResourceFileName));
			}
			XmlAttributeCollection paraAttributes = node.Attributes;

			// Set alignment
			node = paraAttributes.GetNamedItem("alignment");
			if (node != null)
			{
				string sAlign = node.Value;
				int nAlign = (int)FwTextAlign.ktalLeading;
				switch (sAlign)
				{
					case "left":
						break;
					case "center":
						nAlign = (int)FwTextAlign.ktalCenter;
						break;
					case "right":
						nAlign = (int)FwTextAlign.ktalTrailing;
						break;
					case "full":
						nAlign = (int)FwTextAlign.ktalJustify;
						break;
					default:
						ReportInvalidInstallation(String.Format(
							FrameworkStrings.ksUnknownAlignmentValue, styleName, ResourceFileName));
						break;
				}
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptAlign,
					(int)FwTextPropVar.ktpvEnum, nAlign);
			}

			node = paraAttributes.GetNamedItem("background");
			if (node != null && node.Value != "white")
				ReportInvalidInstallation(String.Format(
					FrameworkStrings.ksUnknownBackgroundValue, styleName, ResourceFileName));

			// set leading indentation
			node = paraAttributes.GetNamedItem("indentLeft");
			if (node != null)
			{
				int nLeftIndent = InterpretMeasurementAttribute(node.Value, "indentLeft",
					styleName, ResourceFileName);
				propsBldr.SetIntPropValues(
					(int)FwTextPropType.ktptLeadingIndent,
					(int)FwTextPropVar.ktpvMilliPoint, nLeftIndent);
			}

			// Set trailing indentation
			node = paraAttributes.GetNamedItem("indentRight");
			if (node != null)
			{
				int nRightIndent = InterpretMeasurementAttribute(node.Value, "indentRight",
					styleName, ResourceFileName);
				propsBldr.SetIntPropValues(
					(int)FwTextPropType.ktptTrailingIndent,
					(int)FwTextPropVar.ktpvMilliPoint, nRightIndent);
			}

			// Set first-line/hanging indentation
			int nFirstIndent = 0;
			bool fFirstLineOrHangingIndentSpecified = false;
			node = paraAttributes.GetNamedItem("firstLine");
			if (node != null)
			{
				nFirstIndent = InterpretMeasurementAttribute(node.Value, "firstLine",
					styleName, ResourceFileName);
				fFirstLineOrHangingIndentSpecified = true;
			}
			int nHangingIndent = 0;
			node = paraAttributes.GetNamedItem("hanging");
			if (node != null)
			{
				nHangingIndent = InterpretMeasurementAttribute(node.Value, "hanging",
					styleName, ResourceFileName);
				fFirstLineOrHangingIndentSpecified = true;
			}

			if (nFirstIndent != 0 && nHangingIndent != 0)
				ReportInvalidInstallation(String.Format(
					FrameworkStrings.ksInvalidFirstLineHanging, styleName, ResourceFileName));

			nFirstIndent -= nHangingIndent;
			if (fFirstLineOrHangingIndentSpecified)
			{
				propsBldr.SetIntPropValues(
					(int)FwTextPropType.ktptFirstIndent,
					(int)FwTextPropVar.ktpvMilliPoint,
					nFirstIndent);
			}

			// Set space before
			node = paraAttributes.GetNamedItem("spaceBefore");
			if (node != null)
			{
				int nSpaceBefore = InterpretMeasurementAttribute(node.Value, "spaceBefore",
					styleName, ResourceFileName);
				propsBldr.SetIntPropValues(
					(int)FwTextPropType.ktptSpaceBefore,
					(int)FwTextPropVar.ktpvMilliPoint, nSpaceBefore);
			}

			// Set space after
			node = paraAttributes.GetNamedItem("spaceAfter");
			if (node != null)
			{
				int nSpaceAfter = InterpretMeasurementAttribute(node.Value, "spaceAfter",
					styleName, ResourceFileName);
				propsBldr.SetIntPropValues(
					(int)FwTextPropType.ktptSpaceAfter,
					(int)FwTextPropVar.ktpvMilliPoint, nSpaceAfter);
			}

			// Set lineSpacing
			node = paraAttributes.GetNamedItem("lineSpacingType");
			string sLineSpacingType = "";
			if (node != null)
			{
				sLineSpacingType = node.Value;
				switch (sLineSpacingType)
				{
						//verify valid line spacing types
					case "atleast":
						break;
					case "exact":
						break;
					default:
						ReportInvalidInstallation(String.Format(
							FrameworkStrings.ksUnknownLineSpacingValue, styleName, ResourceFileName));
						break;
				}
			}

			node = paraAttributes.GetNamedItem("lineSpacing");
			if (node != null)
			{
				int lineSpacing = InterpretMeasurementAttribute(node.Value, "lineSpacing", styleName, ResourceFileName);
				if (lineSpacing < 0)
				{
					ReportInvalidInstallation(String.Format(
						FrameworkStrings.ksNegativeLineSpacing, styleName, ResourceFileName));
				}
				if(sLineSpacingType == "exact")
				{
					lineSpacing *= -1; // negative lineSpacing indicates exact line spacing
				}

				propsBldr.SetIntPropValues(
					(int)FwTextPropType.ktptLineHeight,
					(int)FwTextPropVar.ktpvMilliPoint, lineSpacing);
			}

			// Set borders
			node = paraAttributes.GetNamedItem("border");
			if (node != null)
			{
				int nBorder = 0;
				switch (node.Value)
				{
					case "top":
						nBorder = (int)FwTextPropType.ktptBorderTop;
						break;
					case "bottom":
						nBorder = (int)FwTextPropType.ktptBorderBottom;
						break;
					case "leading":
						nBorder = (int)FwTextPropType.ktptBorderLeading;
						break;
					case "trailing":
						nBorder = (int)FwTextPropType.ktptBorderTrailing;
						break;
					default:
						ReportInvalidInstallation(String.Format(
							FrameworkStrings.ksUnknownBorderValue, styleName, ResourceFileName));
						break;
				}
				propsBldr.SetIntPropValues(nBorder, (int)FwTextPropVar.ktpvDefault,
					500);
			}

			node = paraAttributes.GetNamedItem("keepWithNext");
			if (node != null)
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptKeepWithNext,
					(int)FwTextPropVar.ktpvEnum,
					GetBoolAttribute(paraAttributes, "keepWithNext", styleName, ResourceFileName) ?
					(int)FwTextToggleVal.kttvForceOn :
					(int)FwTextToggleVal.kttvOff);
			}

			node = paraAttributes.GetNamedItem("keepTogether");
			if (node != null)
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptKeepTogether,
					(int)FwTextPropVar.ktpvEnum,
					GetBoolAttribute(paraAttributes, "keepTogether", styleName, ResourceFileName) ?
					(int)FwTextToggleVal.kttvForceOn :
					(int)FwTextToggleVal.kttvOff);
			}

			node = paraAttributes.GetNamedItem("widowOrphan");
			if (node != null)
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptWidowOrphanControl,
					(int)FwTextPropVar.ktpvEnum,
					GetBoolAttribute(paraAttributes, "widowOrphan", styleName, ResourceFileName) ?
					(int)FwTextToggleVal.kttvForceOn :
					(int)FwTextToggleVal.kttvOff);
			}
		}
示例#32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Read the font properties from the XML node and set the properties in the given
		/// props builder.
		/// </summary>
		/// <param name="styleName">Name of style being created/updated (for error reporting)
		/// </param>
		/// <param name="styleTag">XML node that has the font properties</param>
		/// <param name="propsBldr">the props builder to store the props</param>
		/// ------------------------------------------------------------------------------------
		protected void SetFontProperties(string styleName, XmlNode styleTag,
			ITsPropsBldr propsBldr)
		{
			// Get character properties
			XmlAttributeCollection fontAttributes =
				styleTag.SelectSingleNode("font").Attributes;

			XmlNode node = fontAttributes.GetNamedItem("italic");
			if (node != null)
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptItalic,
					(int)FwTextPropVar.ktpvEnum,
					GetBoolAttribute(fontAttributes, "italic", styleName, ResourceFileName) ?
					(int)FwTextToggleVal.kttvInvert :
					(int)FwTextToggleVal.kttvOff);
			}

			node = fontAttributes.GetNamedItem("bold");
			if (node != null)
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptBold,
					(int)FwTextPropVar.ktpvEnum,
					GetBoolAttribute(fontAttributes, "bold", styleName, ResourceFileName) ?
					(int)FwTextToggleVal.kttvInvert :
					(int)FwTextToggleVal.kttvOff);
			}

			node = fontAttributes.GetNamedItem("superscript");
			if (node != null)
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
					(int)FwTextPropVar.ktpvEnum,
					GetBoolAttribute(fontAttributes, "superscript", styleName, ResourceFileName) ?
					(int)FwSuperscriptVal.kssvSuper :
					(int)FwSuperscriptVal.kssvOff);
			}

			node = fontAttributes.GetNamedItem("size");
			if (node != null)
			{
				int nSize = InterpretMeasurementAttribute(node.Value, "size", styleName, ResourceFileName);
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptFontSize,
					(int)FwTextPropVar.ktpvMilliPoint, nSize);
			}

			node = fontAttributes.GetNamedItem("color");
			string sColor = (node == null ? "default" : node.Value);
			if (sColor != "default")
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptForeColor,
					(int)FwTextPropVar.ktpvDefault,
					ColorVal(sColor, styleName));
			}

			node = fontAttributes.GetNamedItem("underlineColor");
			sColor = (node == null ? "default" : node.Value);
			if (sColor != "default")
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptUnderColor,
					(int)FwTextPropVar.ktpvDefault,
					ColorVal(sColor, styleName));
			}

			node = fontAttributes.GetNamedItem("underline");
			string sUnderline = (node == null) ? null : node.Value;
			if (sUnderline != null)
			{
				int unt = InterpretUnderlineType(sUnderline);
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptUnderline,
					(int)FwTextPropVar.ktpvEnum,
					unt);
			}

			node = fontAttributes.GetNamedItem("spellcheck");
			bool fSpellcheck = (node == null ? true : (node.Value == "true"));
			if (!fSpellcheck)
			{
				propsBldr.SetIntPropValues((int)FwTextPropType.ktptSpellCheck,
					(int)FwTextPropVar.ktpvEnum, (int)SpellingModes.ksmDoNotCheck);
			}

			// TODO: Handle dropcap attribute

			node = fontAttributes.GetNamedItem("type");
			if (node != null && node.Value != string.Empty)
			{
				string sFontFamily = node.Value;
				switch (sFontFamily)
				{
					case "heading":
						propsBldr.SetStrPropValue(
							(int)FwTextPropType.ktptFontFamily,
							StStyle.DefaultHeadingFont);
						break;
					case "default":
						propsBldr.SetStrPropValue(
							(int)FwTextPropType.ktptFontFamily,
							StStyle.DefaultFont);
						break;
					case "publication":
						propsBldr.SetStrPropValue(
							(int)FwTextPropType.ktptFontFamily,
							StStyle.DefaultPubFont);
						break;
					default:
						ReportInvalidInstallation(String.Format(
							FrameworkStrings.ksUnknownFontType, styleName, ResourceFileName));
						break;
				}
			}
		}
示例#33
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Saves a boolean property value to a props builder that will go to the database.
		/// </summary>
		/// <param name="props">props builder</param>
		/// <param name="boolProp">The boolean property to write</param>
		/// <param name="propTag">The property tag</param>
		/// ------------------------------------------------------------------------------------
		private void SaveBoolProp(ITsPropsBldr props, InheritableStyleProp<bool> boolProp,
			int propTag)
		{
			if (!boolProp.IsInherited)
				props.SetIntPropValues(propTag, 0, boolProp.Value ? 1 : 0);
		}
示例#34
0
		private static void ApplyStyleToTsPropertyBuilder(ITsPropsBldr tpb, string style)
		{
			if (String.IsNullOrEmpty(style))
				return;
			style = style.ToLowerInvariant();
			// N.B.: Was tempted to refactor with IndexOf("-"), but realized
			// that style could be "italic -bold" or "-italic bold" or "-italic -bold".
			if (style.IndexOf("-bold") >= 0)
			{
				tpb.SetIntPropValues((int) FwTextPropType.ktptBold,
									 (int) FwTextPropVar.ktpvEnum,
									 (int) FwTextToggleVal.kttvOff);
			}
			else if (style.IndexOf("bold") >= 0)
			{
				tpb.SetIntPropValues((int) FwTextPropType.ktptBold,
									 (int) FwTextPropVar.ktpvEnum,
									 (int) FwTextToggleVal.kttvForceOn);
			}
			if (style.IndexOf("-italic") >= 0)
			{
				tpb.SetIntPropValues((int) FwTextPropType.ktptItalic,
									 (int) FwTextPropVar.ktpvEnum,
									 (int) FwTextToggleVal.kttvOff);
			}
			else if (style.IndexOf("italic") >= 0)
			{
				tpb.SetIntPropValues((int) FwTextPropType.ktptItalic,
									 (int) FwTextPropVar.ktpvEnum,
									 (int) FwTextToggleVal.kttvForceOn);
			}
		}
示例#35
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Converts this bullet info to a text props object
		/// </summary>
		/// <param name="styleProps">The style props</param>
		/// ------------------------------------------------------------------------------------
		public void ConvertAsTextProps(ITsPropsBldr styleProps)
		{
			if (styleProps == null)
				return;

			styleProps.SetIntPropValues((int)FwTextPropType.ktptBulNumScheme,
				(int)FwTextPropVar.ktpvEnum, (int)m_numberScheme);

			if (m_numberScheme == VwBulNum.kvbnNone)
			{	// no bullets
				styleProps.SetIntPropValues((int)FwTextPropType.ktptBulNumStartAt,
					-1, -1);
				styleProps.SetStrPropValue((int)FwTextPropType.ktptBulNumTxtBef, null);
				styleProps.SetStrPropValue((int)FwTextPropType.ktptBulNumTxtAft, null);
			}
			else if ((int)m_numberScheme >= (int)VwBulNum.kvbnBulletBase)
			{
				// bullets
				styleProps.SetIntPropValues((int)FwTextPropType.ktptBulNumStartAt,
					-1, -1);
				styleProps.SetStrPropValue((int)FwTextPropType.ktptBulNumTxtBef, null);
				styleProps.SetStrPropValue((int)FwTextPropType.ktptBulNumTxtAft, null);
				styleProps.SetStrPropValue((int)FwTextPropType.ktptBulNumFontInfo, EncodedFontInfo);
			}
			else
			{
				// numbered
				styleProps.SetIntPropValues((int)FwTextPropType.ktptBulNumStartAt,
					(int)FwTextPropVar.ktpvDefault, m_start);
				styleProps.SetStrPropValue((int)FwTextPropType.ktptBulNumTxtBef, m_textBefore);
				styleProps.SetStrPropValue((int)FwTextPropType.ktptBulNumTxtAft, m_textAfter);
				styleProps.SetStrPropValue((int)FwTextPropType.ktptBulNumFontInfo, EncodedFontInfo);
			}
		}
示例#36
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds a size property to the specified props builder with the specified prop type.
		/// </summary>
		/// <param name="propsBldr">The props builder.</param>
		/// <param name="value">The string representation of the size value.</param>
		/// <param name="proptype">The property type.</param>
		/// <param name="unitAttr">The attribute containing the size unit (can be null).</param>
		/// <param name="typeAttr">The attribute containing the size type (can be null).</param>
		/// <param name="allowNegative">true if negative size is allowed (e.g., baseline offset)</param>
		/// ------------------------------------------------------------------------------------
		private static void AddSizePropertyToBldr(ITsPropsBldr propsBldr, string value, int proptype,
			XAttribute unitAttr, XAttribute typeAttr, bool allowNegative)
		{
			int var;
			int intValue = GetSizeValue(value, unitAttr, typeAttr, allowNegative, out var);
			propsBldr.SetIntPropValues(proptype, var, intValue);
		}