Exemplo n.º 1
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());
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Add a new real style in the stylesheet for this proxy, if needed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void AddStyleToStylesheet()
        {
            if (m_style != null || m_Context == ContextValues.EndMarker || m_sStyleName == null)
            {
                return;
            }
            // If m_ttpFormattingProps has not been set up, initialize it now
            if (m_ttpFormattingProps == null)
            {
                ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();
                m_ttpFormattingProps = tsPropsBldr.GetTextProps();                 // default properties
            }

            // Get an hvo for the new style
            int hvoStyle = m_FwStyleSheet.MakeNewStyle();

            m_style = m_FwStyleSheet.Cache.ServiceLocator.GetInstance <IStStyleRepository>().GetObject(hvoStyle);

            // PutStyle() adds the style to the stylesheet. we'll give it the properties we
            // are aware of.
            m_FwStyleSheet.PutStyle(m_sStyleName, string.Empty, hvoStyle, 0,
                                    m_StyleType == StyleType.kstParagraph ? hvoStyle : 0, (int)m_StyleType, false, false, m_ttpFormattingProps);

            // base the new style on "Paragraph"
            if (m_StyleType == StyleType.kstParagraph)
            {
                m_style.BasedOnRA = m_FwStyleSheet.FindStyle(ScrStyleNames.NormalParagraph);
                m_style.Context   = m_style.BasedOnRA.Context;
                m_style.Structure = m_style.BasedOnRA.Structure;
                m_style.Function  = m_style.BasedOnRA.Function;
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        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");
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
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");
        }
Exemplo n.º 8
0
        public void GetFootnoteMarkerFromGuid()
        {
            StFootnote footnote = new StFootnote();

            m_scr.ScriptureBooksOS[0].FootnotesOS.Append(footnote);
            footnote.FootnoteMarker.Text = "a";

            Guid guid = m_fdoCache.GetGuidFromId(footnote.Hvo);

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

            byte[] objData = MiscUtils.GetObjData(guid, 1);
            propsBldr.SetStrPropValueRgch(1, objData, objData.Length);

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

            propsBldr.GetStrPropValue(1, out sObjData);

            using (StVc vc = new StVc())
            {
                vc.Cache     = m_fdoCache;
                vc.DefaultWs = m_fdoCache.LanguageWritingSystemFactoryAccessor.UserWs;
                ITsString footnoteMarker = vc.GetStrForGuid(sObjData.Substring(1));

                Assert.AreEqual("2", footnoteMarker.Text);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fdoCache"></param>
        /// <returns></returns>
        public static ITsTextProps PartOfSpeechTextProperties(FdoCache fdoCache, bool inAnalysisLine, bool fUseStyleSheet)
        {
            int          color = (int)CmObjectUi.RGB(Color.Green);
            ITsPropsBldr bldr  = TsPropsBldrClass.Create();

            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());
        }
Exemplo n.º 10
0
        public void MultiStringAlt()
        {
            ITsString tsStringNew = m_ISilDataAccess.get_MultiStringAlt(1117, 2227, 7);

            Assert.IsNotNull(tsStringNew);
            Assert.AreEqual(0, tsStringNew.Length);

            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Verse");
            strBldr.Replace(0, 0, "Test", propsBldr.GetTextProps());
            ITsString tsString = strBldr.GetString();

            m_IVwCacheDa.CacheStringAlt(1117, 2227, 7, tsString);
            tsStringNew = m_ISilDataAccess.get_MultiStringAlt(1117, 2227, 7);
            Assert.AreEqual(tsString, tsStringNew);

            strBldr.Replace(0, 0, "SecondTest", propsBldr.GetTextProps());
            tsString = strBldr.GetString();
            m_IVwCacheDa.CacheStringAlt(1117, 2227, 7, tsString);
            tsStringNew = m_ISilDataAccess.get_MultiStringAlt(1117, 2227, 7);
            Assert.AreEqual(tsString, tsStringNew);

            tsStringNew = m_ISilDataAccess.get_MultiStringAlt(1117, 2227, 8);
            Assert.IsNotNull(tsStringNew);
            Assert.AreEqual(0, tsStringNew.Length);
        }
Exemplo n.º 11
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Static method to create a new structured text. It creates an StText object owned by
        /// hvoOwner in property tag, then creates an StTxtPara owned by the new StText. It
        /// sets the contents of the paragraph to be an empty string in the specified writing system,
        /// and Normal paragraph style.
        /// </summary>
        /// ENHANCE JohnT: probably we will identify styles by something other than name.
        /// REVIEW JohnT(TomB): Are we supposed to be supplying a style name rather than just
        /// using "Normal"?
        ///
        /// <param name="cache">FieldWorks database access</param>
        /// <param name="hvoOwner">id of object to own the new StText</param>
        /// <param name="propTag">property (field) type of the new StText</param>
        /// <param name="ws">language writing system of empty paragraph</param>
        /// <returns>HVO of the newly created StText object</returns>
        /// -----------------------------------------------------------------------------------
        public static int MakeEmptyStText(FdoCache cache, int hvoOwner, int propTag, int ws)
        {
            // REVIEW TomB: Lastparm should really be null if Randy changes CreateObject.

            // Response from RandyR: I changed CreateObject. Null should work for
            // everything now.
            // Most of this code could be moved into the FDO objects, if desired.
            int hvoStText = cache.CreateObject(StText.kclsidStText, hvoOwner, propTag, 0);
            int hvoPara   = cache.CreateObject(StTxtPara.kclsidStTxtPara, hvoStText,
                                               (int)StText.StTextTags.kflidParagraphs, 0);

            // Set the style of the paragraph to Normal
            ITsTextProps ttpNormal;
            ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();

            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                        StyleNames.ksNormal);
            ttpNormal = tsPropsBldr.GetTextProps();
            cache.MainCacheAccessor.SetUnknown(hvoPara,
                                               (int)StPara.StParaTags.kflidStyleRules, ttpNormal);

            // Set its contents to an empty string in the right writing system.
            ITsStrFactory tsFactory = TsStrFactoryClass.Create();

            cache.SetTsStringProperty(hvoPara, (int)StTxtPara.StTxtParaTags.kflidContents,
                                      tsFactory.MakeStringRgch("", 0, ws));

            return(hvoStText);
        }
Exemplo n.º 12
0
        public void StringProp()
        {
            CheckDisposed();
            // Test StringProp
            ITsString tsStringNew = m_ISilDataAccess.get_StringProp(1118, 2228);

            Assert.AreEqual(0, tsStringNew.Length);
            Assert.IsFalse(m_ISilDataAccess.IsDirty());

            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Verse");
            strBldr.Replace(0, 0, "StringPropTest", propsBldr.GetTextProps());
            ITsString tsString = strBldr.GetString();

            m_ISilDataAccess.SetString(1118, 2228, tsString);
            tsStringNew = m_ISilDataAccess.get_StringProp(1118, 2228);
            Assert.AreEqual(tsString, tsStringNew);
            Assert.IsTrue(m_ISilDataAccess.IsDirty());

            strBldr.Replace(0, 0, "Second", propsBldr.GetTextProps());
            tsString = strBldr.GetString();
            m_ISilDataAccess.SetString(1118, 2228, tsString);
            tsStringNew = m_ISilDataAccess.get_StringProp(1118, 2228);
            Assert.AreEqual(tsString, tsStringNew);
            Assert.IsTrue(m_ISilDataAccess.IsDirty());

            CheckProp(1118, 2228, tsString, CellarModuleDefns.kcptString);
        }
Exemplo n.º 13
0
        public void CreateFromStringRep_BT_withBrackets()
        {
            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 = 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);
        }
Exemplo n.º 14
0
        public void CreateFromStringRep_twoCharStylePara()
        {
            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 = 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);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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("__");
        }
Exemplo n.º 17
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);
        }
        public void MergeWritingSystemWithStyleDefnForToWs_DoesNotConvertStyleDefinition()
        {
            IWritingSystem fromWs;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-NO", true, false, out fromWs);
            IWritingSystem toWs;

            WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-SO", true, false, out toWs);
            EnsureAnalysisWs(new[] { fromWs, toWs });

            var style1 = Cache.ServiceLocator.GetInstance <IStStyleFactory>().Create();

            Cache.LangProject.StylesOC.Add(style1);
            var fontOverrides = new Dictionary <int, FontInfo>();
            var fontOverride  = new FontInfo();

            fontOverride.m_italic.ExplicitValue = true;
            fontOverrides[fromWs.Handle]        = fontOverride;
            fontOverride = new FontInfo();
            fontOverride.m_bold.ExplicitValue = true;
            fontOverrides[toWs.Handle]        = fontOverride;
            var bldr = TsPropsBldrClass.Create();

            BaseStyleInfo.SaveFontOverridesToBuilder(fontOverrides, bldr);
            style1.Rules = bldr.GetTextProps();
            m_actionHandler.EndUndoTask();
            UndoableUnitOfWorkHelper.Do("doit", "undoit", m_actionHandler,
                                        () => WritingSystemServices.MergeWritingSystems(Cache, fromWs, toWs));
            var styleInfo    = new BaseStyleInfo(style1);
            var overrideInfo = styleInfo.OverrideCharacterStyleInfo(toWs.Handle);

            Assert.IsNotNull(overrideInfo);
            Assert.That(overrideInfo.Bold.Value, Is.True);
            Assert.That(overrideInfo.Italic.ValueIsSet, Is.False);
        }
Exemplo n.º 19
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));
     }
 }
Exemplo n.º 20
0
        public void AddDeleteStyle()
        {
            var tsPropsBldr        = TsPropsBldrClass.Create();
            var ttpFormattingProps = tsPropsBldr.GetTextProps();             // default properties
            var nStylesOrig        = m_styleSheet.CStyles;

            // get an hvo for the new style
            var hvoStyle = m_styleSheet.MakeNewStyle();
            var style    = Cache.ServiceLocator.GetInstance <IStStyleRepository>().GetObject(hvoStyle);

            // PutStyle() adds the style to the stylesheet
            m_styleSheet.PutStyle("MyNewStyle", "bla", hvoStyle, 0,
                                  hvoStyle, 0, false, false, ttpFormattingProps);

            Assert.AreEqual(nStylesOrig + 1, m_styleSheet.CStyles);
            Assert.AreEqual(ttpFormattingProps, m_styleSheet.GetStyleRgch(0, "MyNewStyle"),
                            "Should get correct format props for the style added");

            // Make style be based on section head and check context
            var baseOnStyle = m_scr.FindStyle(ScrStyleNames.SectionHead);

            m_styleSheet.PutStyle("MyNewStyle", "bla", hvoStyle, baseOnStyle.Hvo,
                                  hvoStyle, 0, false, false, ttpFormattingProps);
            Assert.AreEqual(baseOnStyle.Context, style.Context);

            // Now delete the new style
            m_styleSheet.Delete(hvoStyle);

            // Verfiy the deletion
            Assert.AreEqual(nStylesOrig, m_styleSheet.CStyles);
            Assert.IsNull(m_styleSheet.GetStyleRgch(0, "MyNewStyle"),
                          "Should get null because style is not there");
        }
Exemplo n.º 21
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());
        }
Exemplo n.º 22
0
        public void TsStringsTwoEmpty_ExpectedIntProp()
        {
            CheckDisposed();
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 45);
            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, "", null);

            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 <-1>.",
                s, "Got incorrect explanation of difference");
        }
Exemplo n.º 23
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");
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
        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");
        }
Exemplo n.º 26
0
        public void UnknownTests()
        {
            var      lp           = Cache.LanguageProject;
            var      styleFactory = Cache.ServiceLocator.GetInstance <IStStyleFactory>();
            IStStyle style;

            using (var undoHelper = new NonUndoableUnitOfWorkHelper(m_actionHandler))
            {
                style = styleFactory.Create();
                lp.StylesOC.Add(style);
                undoHelper.RollBack = false;
            }
            // Should be one PC.
            CheckChanges(1, 0, lp.Hvo, LangProjectTags.kflidStyles, 0, 1, 0);
            ClearChanges();

            var userWs = Cache.WritingSystemFactory.UserWs;
            var bldr   = TsPropsBldrClass.Create();

            bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Arial");
            bldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);
            var tpp = bldr.GetTextProps();

            using (var undoHelper = new NonUndoableUnitOfWorkHelper(m_actionHandler))
            {
                style.Rules         = tpp;
                undoHelper.RollBack = false;
            }
            // Should be one PC.
            CheckChanges(1, 0, style.Hvo, StStyleTags.kflidRules, 0, 0, 0);
            ClearChanges();
        }
Exemplo n.º 27
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);
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
0
        public TitleContentsVc(FdoCache cache)
        {
            int           wsUser = cache.DefaultUserWs;
            ITsStrFactory tsf    = TsStrFactoryClass.Create();

            m_tssTitle = tsf.MakeString(ITextStrings.ksTitle, wsUser);
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            tpb.SetIntPropValues((int)FwTextPropType.ktptBold,
                                 (int)FwTextPropVar.ktpvEnum,
                                 (int)FwTextToggleVal.kttvForceOn);
            m_ttpBold = tpb.GetTextProps();
            tpb       = TsPropsBldrClass.Create();
            // Set some padding all around.
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTop,
                                 (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadBottom,
                                 (int)FwTextPropVar.ktpvMilliPoint, 1000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadLeading,
                                 (int)FwTextPropVar.ktpvMilliPoint, 3000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptPadTrailing,
                                 (int)FwTextPropVar.ktpvMilliPoint, 3000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptMarginTrailing,
                                 (int)FwTextPropVar.ktpvMilliPoint, 11000); // 10000 clips right border.
            m_ttpDataCellProps = tpb.GetTextProps();

            m_vtagStTextTitle = cache.MetaDataCacheAccessor.GetFieldId("StText", "Title", false);

            // Set up the array of writing systems we will display for title.
            SetupWritingSystemsForTitle(cache);
        }
Exemplo n.º 30
0
        public void StringPropWrongLengthFmtTest()
        {
            CheckDisposed();

            // Set class first, or it will throw an exception.
            int  hvo  = 1;
            uint clid = SilDataAccess.MetaDataCache.GetClassId("PhEnvironment");

            SilDataAccess.SetInt(hvo, (int)CmObjectFields.kflidCmObject_Class, (int)clid);
            int tag = (int)SilDataAccess.MetaDataCache.GetFieldId("PhEnvironment", "StringRepresentation", false);

            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Verse");
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            // Test StringFields (which are basically the same, except that the
            // format of the parameters is different)
            strBldr.Replace(0, 0, "Third", propsBldr.GetTextProps());
            ITsString tsString = strBldr.GetString();
            int       cbFmt;

            byte[] rgbFmt;
            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(1000, typeof(byte)))
            {
                cbFmt  = tsString.SerializeFmtRgb(arrayPtr, 1000);
                rgbFmt = (byte[])MarshalEx.NativeToArray(arrayPtr, cbFmt, typeof(byte));
            }
            VwCacheDa.CacheStringFields(hvo, tag, tsString.Text,
                                        tsString.Length, rgbFmt, cbFmt - 1);
        }