Example #1
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);
        }
Example #2
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());
        }
Example #3
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);
        }
Example #4
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());
        }
        public void TypingBeforeHyperlink_WithPrecedingItalicsText()
        {
            var selection = MakeMockSelection(false);
            var selHelper = SelectionHelper.s_mockedSelectionHelper =
                MockRepository.GenerateStub <SelectionHelper>();

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

            ITsPropsBldr bldr = m_ttpNormal.GetBldr();

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

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

                IList <object[]> argsSentToSetTypingProps =
                    selection.GetArgumentsForCallsMadeOn(sel => sel.SetTypingProps(null));
                Assert.AreEqual(1, argsSentToSetTypingProps.Count);
                ITsTextProps ttpSentToSetTypingProps = (ITsTextProps)argsSentToSetTypingProps[0][0];
                Assert.AreEqual(1, ttpSentToSetTypingProps.StrPropCount);
                Assert.AreEqual(1, ttpSentToSetTypingProps.IntPropCount);
                int nVar;
                Assert.AreEqual("Italics", ttpSentToSetTypingProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle));
                Assert.AreEqual(911, ttpSentToSetTypingProps.GetIntPropValues((int)FwTextPropType.ktptWs, out nVar));
            }
        }
Example #6
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);
        }
Example #7
0
        public MetaRuleFormulaVc(LcmCache cache, PropertyTable propertyTable)
            : base(cache, propertyTable)
        {
            ITsPropsBldr tpb = TsStringUtils.MakePropsBldr();

            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_inputCtxtProps = tpb.GetTextProps();

            tpb = TsStringUtils.MakePropsBldr();
            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
            tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            tpb.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            m_resultCtxtProps = tpb.GetTextProps();

            tpb = TsStringUtils.MakePropsBldr();
            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, MiscUtils.StandardSansSerif);
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 10000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            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.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            m_colHeaderProps = tpb.GetTextProps();

            tpb = TsStringUtils.MakePropsBldr();
            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, MiscUtils.StandardSansSerif);
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 10000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
            tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            m_rowHeaderProps = tpb.GetTextProps();

            var userWs = m_cache.DefaultUserWs;

            m_inputStr    = TsStringUtils.MakeString(MEStrings.ksMetaRuleInput, userWs);
            m_resultStr   = TsStringUtils.MakeString(MEStrings.ksMetaRuleResult, userWs);
            m_leftEnvStr  = TsStringUtils.MakeString(MEStrings.ksMetaRuleLeftEnv, userWs);
            m_rightEnvStr = TsStringUtils.MakeString(MEStrings.ksMetaRuleRightEnv, userWs);
            m_switchStr   = TsStringUtils.MakeString(MEStrings.ksMetaRuleSwitch, userWs);
        }
Example #8
0
        public void StringProp_ReplaceStringInCache()
        {
            ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();
            ITsStrBldr   strBldr   = TsStringUtils.MakeStrBldr();

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

            m_IVwCacheDa.CacheStringProp(1118, 2228, tsString);
            strBldr.Replace(0, 0, "Second", propsBldr.GetTextProps());
            tsString = strBldr.GetString();
            m_IVwCacheDa.CacheStringProp(1118, 2228, tsString);
            ITsString tsStringNew = m_ISilDataAccess.get_StringProp(1118, 2228);

            Assert.AreEqual(tsString, tsStringNew);
        }
Example #9
0
        protected PatternVcBase(FdoCache cache, Mediator mediator)
        {
            Cache      = cache;
            m_mediator = mediator;

            int userWs      = m_cache.DefaultUserWs;
            int maxFontSize = Cache.ServiceLocator.WritingSystems.AllWritingSystems.Select(ws => GetFontHeight(ws.Handle)).Max();

            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            // specify the writing system, so that font info for a specific WS in the normal style does not override these props
            tpb.SetIntPropValues((int)FwTextPropType.ktptWs, 0, userWs);
            // use Charis SIL because it supports the special characters that are needed for
            // multiline brackets
            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Charis SIL");
            // make the size of the brackets large enough so that they display properly
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, maxFontSize);
            m_bracketProps = tpb.GetTextProps();

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

            ITsStrFactory tsf = m_cache.TsStrFactory;

            m_empty               = tsf.MakeString("", userWs);
            m_leftBracketUpHook   = tsf.MakeString("\u23a1", userWs);
            m_leftBracketExt      = tsf.MakeString("\u23a2", userWs);
            m_leftBracketLowHook  = tsf.MakeString("\u23a3", userWs);
            m_rightBracketUpHook  = tsf.MakeString("\u23a4", userWs);
            m_rightBracketExt     = tsf.MakeString("\u23a5", userWs);
            m_rightBracketLowHook = tsf.MakeString("\u23a6", userWs);
            m_leftBracket         = tsf.MakeString("[", userWs);
            m_rightBracket        = tsf.MakeString("]", userWs);
            m_leftParenUpHook     = tsf.MakeString("\u239b", userWs);
            m_leftParenExt        = tsf.MakeString("\u239c", userWs);
            m_leftParenLowHook    = tsf.MakeString("\u239d", userWs);
            m_rightParenUpHook    = tsf.MakeString("\u239e", userWs);
            m_rightParenExt       = tsf.MakeString("\u239f", userWs);
            m_rightParenLowHook   = tsf.MakeString("\u23a0", userWs);
            m_leftParen           = tsf.MakeString("(", userWs);
            m_rightParen          = tsf.MakeString(")", userWs);
            m_questions           = tsf.MakeString("???", userWs);
            m_zwSpace             = tsf.MakeString("\u200b", userWs);
        }
        public MetaRuleFormulaVc(FdoCache cache, XCore.Mediator mediator)
            : base(cache, mediator)
        {
            ITsPropsBldr tpb = TsPropsBldrClass.Create();

            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_inputCtxtProps = tpb.GetTextProps();

            tpb = TsPropsBldrClass.Create();
            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalCenter);
            tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            tpb.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            m_resultCtxtProps = tpb.GetTextProps();

            tpb = TsPropsBldrClass.Create();
            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Arial");
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 10000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptBorderColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            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.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            m_colHeaderProps = tpb.GetTextProps();

            tpb = TsPropsBldrClass.Create();
            tpb.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Arial");
            tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 10000);
            tpb.SetIntPropValues((int)FwTextPropType.ktptForeColor, (int)FwTextPropVar.ktpvDefault,
                                 (int)ColorUtil.ConvertColorToBGR(Color.Gray));
            tpb.SetIntPropValues((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft);
            tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
            m_rowHeaderProps = tpb.GetTextProps();

            m_inputStr    = m_cache.MakeUserTss(MEStrings.ksMetaRuleInput);
            m_resultStr   = m_cache.MakeUserTss(MEStrings.ksMetaRuleResult);
            m_leftEnvStr  = m_cache.MakeUserTss(MEStrings.ksMetaRuleLeftEnv);
            m_rightEnvStr = m_cache.MakeUserTss(MEStrings.ksMetaRuleRightEnv);
            m_switchStr   = m_cache.MakeUserTss(MEStrings.ksMetaRuleSwitch);
        }
Example #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Set a font face name for a style.
        /// </summary>
        /// <param name="styleName"></param>
        /// <param name="fontName"></param>
        /// ------------------------------------------------------------------------------------
        public void SetStyleFont(string styleName, string fontName)
        {
            IStStyle     style   = FindStyle(styleName);
            ITsPropsBldr ttpBldr = style.Rules.GetBldr();

            ttpBldr.SetStrPropValue((int)FwTextPropType.ktptFontFamily, fontName);
            style.Rules = ttpBldr.GetTextProps();
            ComputeDerivedStyles();
        }
Example #12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns paragraph textprops representing a paragraph style of the given name.
        /// </summary>
        /// <param name="styleName">The name of the paragraph style</param>
        /// <returns>A TsTextProps object wich will have exactly zero int props and one string
        /// prop: the named style, whose value will be the given styleName</returns>
        /// <remarks>This is useful for setting BaseStPara.StyleRules.</remarks>
        /// ------------------------------------------------------------------------------------
        public static ITsTextProps ParaStyleTextProps(string styleName)
        {
            Debug.Assert(!string.IsNullOrEmpty(styleName));

            // Build props for the given para style name
            ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();

            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, styleName);
            return(tsPropsBldr.GetTextProps());
        }
Example #13
0
        /// <summary>
        /// Appends the specified string to end of the current text.
        /// </summary>
        public void Append(string bstrIns)
        {
            if (string.IsNullOrEmpty(bstrIns))
            {
                return;
            }

            m_text.Append(bstrIns);

            var newRun = new TsRun(m_text.Length, (TsTextProps)m_propsBldr.GetTextProps());

            if (m_runs.Count > 0 && m_runs[m_runs.Count - 1].TextProps.Equals(newRun.TextProps))
            {
                m_runs[m_runs.Count - 1] = newRun;
            }
            else
            {
                m_runs.Add(newRun);
            }
        }
Example #14
0
        public void Setup()
        {
            tsf   = TsStrFactoryClass.Create();
            wsf   = new MockWsf();
            wsEn  = wsf.GetWsFromStr("en");
            wsFrn = wsf.GetWsFromStr("fr");
            ITsPropsBldr propBldr = TsPropsBldrClass.Create();

            propBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, wsFrn);
            ttpFrn = propBldr.GetTextProps();
        }
        public void SerializeTsStringToXml_WithExternalLink()
        {
            ITsPropsBldr tpb = TsStringUtils.MakePropsBldr();

            tpb.SetIntValue(FwTextPropType.ktptWs, FwTextPropVar.ktpvDefault, EnWS);
            tpb.SetStringValue(FwTextPropType.ktptObjData, CreateObjData(FwObjDataTypes.kodtExternalPathName, "C:\\Idont\\exist\\here.doc"));
            ITsString tss = TsStringUtils.MakeString("document", tpb.GetTextProps());
            string    xml = TsStringSerializer.SerializeTsStringToXml(tss, WritingSystemManager);

            Assert.That(StripNewLines(xml), Is.EqualTo("<Str><Run ws=\"en\" externalLink=\"C:\\Idont\\exist\\here.doc\">document</Run></Str>"));
        }
        public void SerializeTsStringToXml_WithEmbeddedData()
        {
            ITsPropsBldr tpb = TsStringUtils.MakePropsBldr();

            tpb.SetIntValue(FwTextPropType.ktptWs, FwTextPropVar.ktpvDefault, EnWS);
            tpb.SetStringValue(FwTextPropType.ktptObjData, CreateObjData(FwObjDataTypes.kodtEmbeddedObjectData, "<FN><M>a</M></FN>"));
            ITsString tss = TsStringUtils.MakeString("a", tpb.GetTextProps());
            string    xml = TsStringSerializer.SerializeTsStringToXml(tss, WritingSystemManager);

            Assert.That(StripNewLines(xml), Is.EqualTo("<Str><Run ws=\"en\" embedded=\"&lt;FN&gt;&lt;M&gt;a&lt;/M&gt;&lt;/FN&gt;\">a</Run></Str>"));
        }
Example #17
0
		/// <summary>
		/// Make a TsString in the specified (typicaly UI) writing system, which is forced to be
		/// displayed in the default UIElement style.
		/// </summary>
		protected ITsString MakeUiElementString(string text, int uiWs, Action<ITsPropsBldr> SetAdditionalProps)
		{
			ITsStrBldr bldr = TsStringUtils.MakeStrBldr();
			ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();
			propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, uiWs);
			propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, StyleServices.UiElementStylename);
			if (SetAdditionalProps != null)
				SetAdditionalProps(propsBldr);
			bldr.Replace(0, 0, text, propsBldr.GetTextProps());
			return bldr.GetString();
		}
Example #18
0
        protected ITsString MakeSimpleString(String str)
        {
            ITsStrBldr   builder = TsStrBldrClass.Create();
            ITsPropsBldr bldr    = TsPropsBldrClass.Create();

            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());
        }
Example #19
0
        public void PropsAreEqual()
        {
            // test of same int prop: writing system
            ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();

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

            Assert.IsTrue(TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out s));

            // test of same int & string props
            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                        "my style"); //add string prop to prior int prop
            ttp1 = tsPropsBldr.GetTextProps();
            ttp2 = tsPropsBldr.GetTextProps();
            Assert.IsTrue(TsTextPropsHelper.PropsAreEqual(ttp1, ttp2, out s));
            Assert.AreEqual("TextProps objects appear to contain the same properties.", s);
        }
Example #20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns paragraph textprops representing a paragraph style of the given name.
        /// </summary>
        /// <param name="styleName">The name of the paragraph style</param>
        /// <returns>A TsTextProps object wich will have exactly zero int props and one string
        /// prop: the named style, whose value will be the given styleName</returns>
        /// <remarks>This is useful for setting BaseStPara.StyleRules.</remarks>
        /// ------------------------------------------------------------------------------------
        static public ITsTextProps ParaStyleTextProps(string styleName)
        {
            Debug.Assert(styleName != null && styleName.Length > 0);

            // Build props for the given para style name
            ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();

            //ITsPropsBldr tsPropsBldr = TsPropsBldrClass.Create();
            tsPropsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle,
                                        styleName);
            return(tsPropsBldr.GetTextProps());
        }
Example #21
0
        public void UnknownProp()
        {
            object obj = m_ISilDataAccess.get_UnknownProp(1120, 2220);

            Assert.IsNull(obj);

            ITsPropsBldr propsBldr = TsStringUtils.MakePropsBldr();
            ITsTextProps ttp       = propsBldr.GetTextProps();

            m_IVwCacheDa.CacheUnknown(1120, 2220, ttp);
            obj = m_ISilDataAccess.get_UnknownProp(1120, 2220);
            Assert.AreEqual(ttp, obj);
        }
        public void TsStringsDifferByRunFormat()
        {
            ITsStrBldr   strBldr   = TsStrBldrClass.Create();
            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, (int)FwTextPropVar.ktpvDefault, 45);
            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bogus");
            ITsTextProps propsBogus = propsBldr.GetTextProps();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bogle");
            ITsTextProps propsBogle = propsBldr.GetTextProps();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bugle");
            ITsTextProps propsBugle = propsBldr.GetTextProps();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Bungle");
            ITsTextProps propsBungle = propsBldr.GetTextProps();

            // Create TsString #1: "Weird /|Bogus{Test} /Dude"
            strBldr.Replace(0, 0, "Dude", propsBungle);
            strBldr.Replace(0, 0, "Test ", propsBogus);
            strBldr.Replace(0, 0, "Weird ", propsBugle);
            ITsString tssExpected = strBldr.GetString();

            // Create TsString #2: "Weird /|Bogle{Test} /Dude"
            strBldr = TsStrBldrClass.Create();
            strBldr.Replace(0, 0, "Dude", propsBungle);
            strBldr.Replace(0, 0, "Test ", propsBogle);
            strBldr.Replace(0, 0, "Weird ", propsBugle);

            string s;

            Assert.IsFalse(TsStringHelper.TsStringsAreEqual(tssExpected, strBldr.GetString(),
                                                            out s));
            Assert.AreEqual(
                "TsStrings differ in format of run 2." + Environment.NewLine +
                "\tProps differ in ktptNamedStyle property. Expected <Bogus>, but was <Bogle>.",
                s, "Got incorrect explanation of difference");
        }
Example #23
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();
        }
Example #24
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());
        }
Example #25
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Returns run textprops representing a character style of the given name.
        /// </summary>
        /// <param name="styleName">The name of the character style, or null to get props for
        /// "Default Paragraph Characters"</param>
        /// <param name="ws">The writing system</param>
        /// <returns>requested text props</returns>
        /// <remarks>If styleName is not given, the resulting props contains only the
        /// vernacular writing system.</remarks>
        /// <remarks>For char style, props should contain ws (writing system) and char style
        /// name. Without a char style, props should contain ws only.
        /// We'll use the vernacular ws.</remarks>
        /// <remarks>Useful for setting run props for an <see cref="ITsString"/>.</remarks>
        /// ------------------------------------------------------------------------------------
        public static ITsTextProps CharStyleTextProps(string styleName, int ws)
        {
            // Build props for the given writing system.
            Debug.Assert(ws != 0);
            ITsPropsBldr bldr = TsPropsBldrClass.Create();

            bldr.SetIntPropValues((int)FwTextPropType.ktptWs, ws == -1 ? -1 : 0, ws);
            // If a style name is given, set that too.
            if (!String.IsNullOrEmpty(styleName))
            {
                bldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, styleName);
            }
            return(bldr.GetTextProps());
        }
Example #26
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            m_callbacks.Stub(x => x.EditedRootBox).Return(m_rootbox);
            m_rootbox.Stub(rbox => rbox.Site).Return(m_rootsite);
            m_rootbox.DataAccess = MockRepository.GenerateMock <ISilDataAccess>();
            m_rootsite.Stub(site => site.GetGraphics(Arg <IVwRootBox> .Is.Equal(m_rootbox),
                                                     out Arg <IVwGraphics> .Out(m_vg).Dummy,
                                                     out Arg <Rect> .Out(new Rect()).Dummy,
                                                     out Arg <Rect> .Out(new Rect()).Dummy));

            ITsPropsBldr ttpBldr = TsStringUtils.MakePropsBldr();

            ttpBldr.SetIntPropValues((int)FwTextPropType.ktptWs, -1, 911);
            m_ttpNormal = ttpBldr.GetTextProps();
            ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Hyperlink");
            char   chOdt = Convert.ToChar((int)FwObjDataTypes.kodtExternalPathName);
            string sRef  = chOdt.ToString() + "http://www.google.com";

            ttpBldr.SetStrPropValue((int)FwTextPropType.ktptObjData, sRef);
            m_ttpHyperlink = ttpBldr.GetTextProps();
        }
Example #27
0
        public void UnknownProp()
        {
            CheckDisposed();
            object obj = m_ISilDataAccess.get_UnknownProp(1120, 2220);

            Assert.IsNull(obj);

            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
            ITsTextProps ttp       = propsBldr.GetTextProps();

            m_IVwCacheDa.CacheUnknown(1120, 2220, ttp);
            obj = m_ISilDataAccess.get_UnknownProp(1120, 2220);
            Assert.AreEqual(ttp, obj);
        }
Example #28
0
        public void TestTsStringWrapperRoundTrip(string str1, string namedStyle1, string str2, string namedStyle2)
        {
            var          wsFact  = new WritingSystemManager();
            ITsStrBldr   bldr    = TsStringUtils.MakeStrBldr();
            ITsPropsBldr ttpBldr = TsStringUtils.MakePropsBldr();

            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);
        }
        public void ParagraphBreak_RemoveCharStyleFromAdjacentWhiteSpace()
        {
            CheckDisposed();
            m_draftView.RefreshDisplay();

            // *** Test setup ***
            // Insert text with a character style.
            StTxtPara    para1   = (StTxtPara)m_exodus.SectionsOS[0].ContentOA.ParagraphsOS[0];
            ITsStrBldr   tssBldr = para1.Contents.UnderlyingTsString.GetBldr();
            ITsPropsBldr ttpBldr = TsPropsBldrClass.Create();

            ttpBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Emphasis");
            tssBldr.ReplaceRgch(15, 15, "really,  really", 6, ttpBldr.GetTextProps());
            int paraCount = m_exodus.SectionsOS[0].ContentOA.ParagraphsOS.Count;

            // Set the IP in the white space within the inserted text.
            m_draftView.SetInsertionPoint(0, 0, 0, 23, true);
            IVwSelection sel0 = m_draftView.RootBox.Selection;

            Assert.IsNotNull(sel0);

            // Insert paragraph break
            m_draftView.OnKeyPress(new KeyPressEventArgs('\r'));

            Assert.AreEqual(paraCount + 1, m_exodus.SectionsOS[0].ContentOA.ParagraphsOS.Count,
                            "Should have one more paragraph in the intro section");

            // We expect that the last run of the first paragraph and first run of the new
            // paragraph will be a space character with no character style.
            ITsString tss1 = para1.Contents.UnderlyingTsString;

            Assert.AreEqual(3, tss1.RunCount, "First intro paragraph should have three runs");
            Assert.AreEqual("really,", tss1.get_RunText(1));
            ITsTextProps ttp = tss1.get_Properties(1);

            Assert.AreEqual("Emphasis", ttp.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle));
            ttp = tss1.get_Properties(2);
            Assert.AreEqual(" ", tss1.get_RunText(2));
            Assert.AreEqual(null, ttp.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle));

            ITsString tss2 = ((StTxtPara)m_exodus.SectionsOS[0].ContentOA.ParagraphsOS[1]).Contents.UnderlyingTsString;

            Assert.AreEqual(3, tss2.RunCount);
            Assert.AreEqual(" ", tss2.get_RunText(0));
            ttp = tss1.get_Properties(0);
            Assert.AreEqual(null, ttp.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle));
            ttp = tss1.get_Properties(1);
            Assert.AreEqual("Emphasis", ttp.GetStrPropValue((int)FwTextStringProp.kstpNamedStyle));
            Assert.AreEqual("really", tss2.get_RunText(0));
        }
Example #30
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());
        }