Пример #1
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);
		}
Пример #2
0
		public AffixRuleFormulaVc(FdoCache cache, XCore.Mediator mediator)
			: base(cache, mediator)
		{
			ITsPropsBldr tpb = TsPropsBldrClass.Create();
			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.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
			m_headerProps = tpb.GetTextProps();

			tpb = TsPropsBldrClass.Create();
			tpb.SetIntPropValues((int)FwTextPropType.ktptBold, (int)FwTextPropVar.ktpvEnum, (int)FwTextToggleVal.kttvForceOn);
			tpb.SetIntPropValues((int)FwTextPropType.ktptFontSize, (int)FwTextPropVar.ktpvMilliPoint, 24000);
			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.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Charis SIL");
			tpb.SetIntPropValues((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum, (int)TptEditable.ktptNotEditable);
			m_arrowProps = tpb.GetTextProps();

			tpb = TsPropsBldrClass.Create();
			tpb.SetIntPropValues((int)FwTextPropType.ktptBorderTop, (int)FwTextPropVar.ktpvMilliPoint, 1000);
			tpb.SetIntPropValues((int)FwTextPropType.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
			tpb.SetIntPropValues((int)FwTextPropType.ktptBorderTrailing, (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.ktptBorderBottom, (int)FwTextPropVar.ktpvMilliPoint, 1000);
			tpb.SetIntPropValues((int)FwTextPropType.ktptBorderTrailing, (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);
			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_indexProps = tpb.GetTextProps();

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

			var tsf = m_cache.TsStrFactory;
			var userWs = m_cache.DefaultUserWs;
			m_inputStr = tsf.MakeString(MEStrings.ksAffixRuleInput, userWs);
			m_indexStr = tsf.MakeString(MEStrings.ksAffixRuleIndex, userWs);
			m_resultStr = tsf.MakeString(MEStrings.ksAffixRuleResult, userWs);
			m_doubleArrow = tsf.MakeString("\u21d2", userWs);
			m_space = tsf.MakeString(" ", userWs);
		}
Пример #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get an XML representation of the given ITsTextProps.
		/// </summary>
		/// <param name="ttp">The TTP.</param>
		/// <param name="wsf">The WSF.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public static string GetXmlRep(ITsTextProps ttp, ILgWritingSystemFactory wsf)
		{
			using (var writer = new StringWriter())
			{
				var stream = new TextWriterStream(writer);
				ttp.WriteAsXml(stream, wsf, 0);
				return writer.ToString();
			}
		}
Пример #4
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();
		}
Пример #5
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();
		}
Пример #6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Checks the final space in reference label.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void CheckFinalSpaceInReferenceLabel(ITsString tss)
        {
            int iRun = tss.RunCount - 1;

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

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

            Assert.AreEqual(Cache.WritingSystemFactory.UserWs,
                            ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var));
        }
Пример #7
0
        public void TitleSecondary()
        {
            CheckDisposed();

            ITsString    tssParas = null;
            ITsTextProps ttpSrc1  = StyleUtils.CharStyleTextProps("Title Secondary", 1);

            VwInsertDiffParaResponse resp = m_draftView.OnInsertDiffParas(
                m_draftView.RootBox, null, 1,
                new ITsTextProps[] { ttpSrc1 }, new ITsString[] { tssParas }, null);

            Assert.AreEqual(VwInsertDiffParaResponse.kidprFail, resp);
        }
Пример #8
0
 /// <summary>
 /// Make one.
 /// </summary>
 /// <param name="wrappedFragId"></param>
 /// <param name="creator"></param>
 /// <param name="paraStyle"></param>
 /// <param name="before"></param>
 /// <param name="listDelimitNode"></param>
 /// <param name="number"></param>
 /// <param name="delayNumber"></param>
 /// <param name="xaNum"></param>
 /// <param name="ttpNum"></param>
 public WrapParagraphDisplayCommand(int wrappedFragId, XmlVcDisplayVec creator, string paraStyle, ITsString before, XmlNode listDelimitNode,
                                    bool number, bool delayNumber, XmlAttribute xaNum, ITsTextProps ttpNum)
 {
     WrappedFragId     = wrappedFragId;
     m_creator         = creator;
     m_paraStyle       = paraStyle;
     m_tssBefore       = before;
     m_listDelimitNode = listDelimitNode;
     m_numberItems     = number;
     m_delayNumber     = delayNumber;
     m_xaNum           = xaNum;
     m_ttpNum          = ttpNum;
 }
Пример #9
0
        public void CreateScrSection_AtEndOfIntro()
        {
            CheckDisposed();

            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null,
                                                                   Cache.DefaultVernWs);

            ScrSection.CreateScrSection(m_philemon, 2, "New content of the new section", textProps, true);
            Assert.AreEqual(5, m_philemon.SectionsOS.Count);
            VerifyInsertedBookSection((ScrSection)m_philemon.SectionsOS[2], true,
                                      "New content of the new section",
                                      null, Cache.DefaultVernWs, 57001000); // intro section
        }
Пример #10
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="XmlTextRun"/> class, based on the given
        /// run information
        /// </summary>
        /// <param name="wsDefault">The default writing system of the paragraph.</param>
        /// <param name="lgwsf">The writing system factory.</param>
        /// <param name="text">The text of the run.</param>
        /// <param name="props">The properties of the run.</param>
        /// ------------------------------------------------------------------------------------
        public XmlTextRun(int wsDefault, ILgWritingSystemFactory lgwsf, string text,
                          ITsTextProps props)
        {
            int dummy;
            int wsRun = props.GetIntPropValues((int)FwTextPropType.ktptWs, out dummy);

            if (wsRun != wsDefault)
            {
                IcuLocale = lgwsf.GetStrFromWs(wsRun);
            }
            StyleName = props.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
            m_text    = text;
        }
Пример #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determine the default font to use for the specified writing system,
        /// displayed in the default Normal style of the specified stylesheet.
        /// This is duplicated in SimpleRootSite/EditingHelper.
        /// </summary>
        /// <param name="hvoWs"></param>
        /// <param name="styleSheet"></param>
        /// <param name="wsf"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        static public Font GetFontForNormalStyle(int hvoWs, IVwStylesheet styleSheet,
                                                 ILgWritingSystemFactory wsf)
        {
            ITsTextProps ttpNormal = styleSheet.NormalFontStyle;
            string       styleName = StStyle.NormalStyleName;

            if (ttpNormal != null)
            {
                styleName = ttpNormal.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
            }

            return(GetFontForStyle(styleName, styleSheet, hvoWs, wsf));
        }
Пример #12
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);
        }
Пример #13
0
        public void MakeProps_NonNullStyle_CreatesTextProps()
        {
            var          tpf = new TsPropsFactory();
            ITsTextProps tps = tpf.MakeProps("Style", 2, 1);

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

            Assert.That(tps.GetIntPropValues((int)FwTextPropType.ktptWs, out var), Is.EqualTo(2));
            Assert.That(var, Is.EqualTo(1));
            Assert.That(tps.StrPropCount, Is.EqualTo(1));
            Assert.That(tps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle), Is.EqualTo("Style"));
        }
Пример #14
0
        public void NormalTextScaling()
        {
            // Set up a ScripturePublication of 9 on 11 pts (base character size on line spacing).
            m_pub.BaseFontSize    = 9000;
            m_pub.BaseLineSpacing = -11000;
            IVwStylesheet stylesheet;
            int           nVar;

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

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

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

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

            // We expect that these styles will be overridden for space before/after at 91.667% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(33000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(11000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(7333, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(3667, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
Пример #15
0
        public void CorrectionPrintoutLineSpacing()
        {
            // Set up a ScripturePublication with no scaling specified.
            m_pub.BaseFontSize    = 12000;
            m_pub.BaseLineSpacing = -36000;
            DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                TeViewType.Correction, m_realStylesheet);
            IVwStylesheet stylesheet    = scrPub.StyleSheet;
            ITsTextProps  ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
            int           nVar;

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

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

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

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

            // We expect that these styles will have unchanged space before/after values.
            // REVIEW: Should we zero out any space before or after for the correction printout view to
            // achieve consistent line spacing?
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(36000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(12000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(8000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(4000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
Пример #16
0
        public void UserPromptChangeWSWhenPasting()
        {
            CheckDisposed();

            // Set up section head with an empty paragraph
            IScrSection section = m_inMemoryCache.AddSectionToMockedBook(m_book.Hvo);
            StTxtPara   para    = m_inMemoryCache.AddSectionHeadParaToSection(section.Hvo, "",
                                                                              ScrStyleNames.SectionHead);

            section.AdjustReferences();

            Options.ShowEmptyParagraphPromptsSetting = true;
            DynamicMock rootb = new DynamicMock(typeof(IVwRootBox));

            rootb.SetupResult("IsCompositionInProgress", false);
            DynamicMock vwsel       = new DynamicMock(typeof(IVwSelection));
            IVwRootBox  mockRootbox = (IVwRootBox)rootb.MockInstance;

            vwsel.SetupResult("RootBox", mockRootbox);
            vwsel.SetupResult("CLevels", 4, typeof(bool));
            vwsel.Ignore("AllTextSelInfo");
#if DEBUG
            vwsel.SetupResult("IsValid", true);
#endif

            DummyTeStVc stVc = new DummyTeStVc(m_inMemoryCache.Cache,
                                               m_inMemoryCache.Cache.DefaultAnalWs, mockRootbox);

            // set up the text to paste - will be TE2ST with vernacular WS
            int             ws       = m_inMemoryCache.Cache.DefaultVernWs;
            ITsPropsFactory propFact = TsPropsFactoryClass.Create();
            ITsTextProps    ttp      = propFact.MakeProps(null, ws, 0);
            ITsStrBldr      bldr     = TsStrBldrClass.Create();
            bldr.ReplaceRgch(0, 0, "TEST", 4, ttp);
            ttp = propFact.MakeProps(ScrStyleNames.VerseNumber, ws, 0);
            bldr.ReplaceRgch(2, 2, "2", 1, ttp);
            ITsString tssVal = bldr.GetString();

            // Now simulate the user pasting over the user prompt
            stVc.UpdateProp((IVwSelection)vwsel.MockInstance, para.Hvo,
                            SimpleRootSite.kTagUserPrompt, 0, tssVal);

            // verify that the text is in the paragraph, that there is no longer a user
            // prompt, and that the ws changed but the character formatting survives.
            bldr = tssVal.GetBldr();
            bldr.SetIntPropValues(0, 5, (int)FwTextPropType.ktptWs,
                                  (int)FwTextPropVar.ktpvDefault, m_inMemoryCache.Cache.DefaultAnalWs);
            AssertEx.AreTsStringsEqual(bldr.GetString(), para.Contents.UnderlyingTsString);

            m_vwenvMock.Verify();
        }
Пример #17
0
        public void HugeTextScaling()
        {
            // Set up a ScripturePublication of 4 on 6 pts (base character size on line spacing).
            m_pub.BaseFontSize    = 120000;
            m_pub.BaseLineSpacing = -120020;
            IVwStylesheet stylesheet;
            int           nVar;

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

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

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

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

            // We expect that these styles will be overridden for space before/after at 1000.1667% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(360060, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(120020, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(80013, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(40007, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
Пример #18
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);
        }
Пример #19
0
        /// <summary>
        /// Get the name of the paragraph style.
        /// </summary>
        /// <param name="hvoPara">the id of the paragraph</param>
        /// <param name="cache">database cache</param>
        public static string GetStyleName(int hvoPara, FdoCache cache)
        {
            ISilDataAccess dataAccess  = cache.MainCacheAccessor;
            ITsTextProps   tsTextProps = dataAccess.get_UnknownProp(hvoPara,
                                                                    (int)StPara.StParaTags.kflidStyleRules) as ITsTextProps;
            string styleName = NormalParagraph;

            if (tsTextProps != null)
            {
                styleName = tsTextProps.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);
            }

            return(styleName);
        }
Пример #20
0
        public void CreateScrSection_AtEndOfBook()
        {
            CheckDisposed();

            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null,
                                                                   Cache.DefaultVernWs);

            ScrSection.CreateScrSection(m_philemon, 4, "New content of section", textProps, false);
            Assert.AreEqual(5, m_philemon.SectionsOS.Count);
            ScrSection section = (ScrSection)m_philemon.SectionsOS[4];

            VerifyInsertedBookSection(section, false, "New content of section",
                                      null, Cache.DefaultVernWs, 57001007); // scripture section
        }
Пример #21
0
        /// <summary>
        /// Attempts to get the value of the specified int property.
        /// </summary>
        public static bool TryGetIntValue(this ITsTextProps textProps, FwTextPropType tpt, out FwTextPropVar var, out int value)
        {
            int v;

            value = textProps.GetIntPropValues((int)tpt, out v);
            if (v == -1 && value == -1)
            {
                var = FwTextPropVar.ktpvDefault;
                return(false);
            }

            var = (FwTextPropVar)v;
            return(true);
        }
Пример #22
0
        public void CreateScrSection_AtStartOfBook()
        {
            CheckDisposed();

            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null,
                                                                   Cache.DefaultVernWs);

            ScrSection.CreateScrSection(m_philemon, 0, "New section", textProps, true);
            Assert.AreEqual(5, m_philemon.SectionsOS.Count);
            ScrSection section = (ScrSection)m_philemon.SectionsOS[0];

            VerifyInsertedBookSection(section, true, "New section", null,
                                      Cache.DefaultVernWs, 57001000); // intro section
        }
Пример #23
0
        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));
        }
Пример #24
0
        public void CreateScrSection_AtStartOfFirstScriptureSection()
        {
            CheckDisposed();

            ITsTextProps textProps = StyleUtils.CharStyleTextProps(null,
                                                                   Cache.DefaultVernWs);

            ScrSection.CreateScrSection(m_philemon, 2, "New section", textProps, false);
            Assert.AreEqual(5, m_philemon.SectionsOS.Count);
            ScrSection section = (ScrSection)m_philemon.SectionsOS[2];

            VerifyInsertedBookSection(section, false, "New section", null,
                                      Cache.DefaultVernWs, 57001001); // new first Scripture section
        }
Пример #25
0
        public void IntroParagraphIntoLine2()
        {
            CheckDisposed();

            ITsString    tssParas = null;
            ITsTextProps ttpSrc1  = StyleUtils.CharStyleTextProps("Intro Paragraph", 1);
            ITsTextProps ttpSrc2  = StyleUtils.CharStyleTextProps("Line2", 1);

            VwInsertDiffParaResponse resp = m_draftView.OnInsertDiffParas(
                m_draftView.RootBox, ttpSrc2, 1,
                new ITsTextProps[] { ttpSrc1 }, new ITsString[] { tssParas }, null);

            Assert.AreEqual(VwInsertDiffParaResponse.kidprFail, resp);
        }
Пример #26
0
        public void SectionHeadIntoSectionHeadMajor()
        {
            CheckDisposed();

            ITsString    tssParas = null;
            ITsTextProps ttpSrc1  = StyleUtils.CharStyleTextProps("Section Head", 1);
            ITsTextProps ttpSrc2  = StyleUtils.CharStyleTextProps("Section Head Major", 1);

            VwInsertDiffParaResponse resp = m_draftView.OnInsertDiffParas(
                m_draftView.RootBox, ttpSrc2, 1,
                new ITsTextProps[] { ttpSrc1 }, new ITsString[] { tssParas }, null);

            Assert.AreEqual(VwInsertDiffParaResponse.kidprDefault, resp);
        }
Пример #27
0
		/// <summary>
		/// Get an array of SelLevInfo structs from the given selection.
		/// </summary>
		/// <param name="vwsel"></param>
		/// <param name="cvsli"></param>
		/// <param name="ihvoRoot"></param>
		/// <param name="tagTextProp"></param>
		/// <param name="cpropPrevious"></param>
		/// <param name="ichAnchor"></param>
		/// <param name="ichEnd"></param>
		/// <param name="ws"></param>
		/// <param name="fAssocPrev"></param>
		/// <param name="ihvoEnd"></param>
		/// <param name="ttp"></param>
		/// <returns></returns>
		public static SelLevInfo[] AllTextSelInfo(IVwSelection vwsel, int cvsli,
			out int ihvoRoot, out int tagTextProp, out int cpropPrevious, out int ichAnchor,
			out int ichEnd, out int ws, out bool fAssocPrev, out int ihvoEnd, out ITsTextProps ttp)
		{
			Debug.Assert(vwsel != null);

			using (ArrayPtr rgvsliPtr = MarshalEx.ArrayToNative<SelLevInfo>(cvsli))
			{
				vwsel.AllTextSelInfo(out ihvoRoot, cvsli, rgvsliPtr,
					out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
					out ws, out fAssocPrev, out ihvoEnd, out ttp);
				return MarshalEx.NativeToArray<SelLevInfo>(rgvsliPtr, cvsli);
			}
		}
Пример #28
0
        public void CitationLine1IntoParagraph()
        {
            CheckDisposed();

            ITsString    tssParas = null;
            ITsTextProps ttpSrc1  = StyleUtils.ParaStyleTextProps("Paragraph");
            ITsTextProps ttpSrc2  = StyleUtils.ParaStyleTextProps("Citation Line1");

            VwInsertDiffParaResponse resp = m_draftView.OnInsertDiffParas(
                m_draftView.RootBox, ttpSrc1, 2,
                new ITsTextProps[] { ttpSrc1, ttpSrc2 }, new ITsString[] { tssParas, tssParas }, null);

            Assert.AreEqual(VwInsertDiffParaResponse.kidprDefault, resp);
        }
Пример #29
0
        public void ParagraphAndTitleMain()
        {
            CheckDisposed();

            ITsString    tssParas = null;
            ITsTextProps ttpSrc1  = StyleUtils.ParaStyleTextProps("Paragraph");
            ITsTextProps ttpSrc2  = StyleUtils.ParaStyleTextProps("Title Main");

            VwInsertDiffParaResponse resp = m_draftView.OnInsertDiffParas(
                m_draftView.RootBox, null, 2,
                new ITsTextProps[] { ttpSrc1, ttpSrc2 }, new ITsString[] { tssParas, tssParas }, null);

            Assert.AreEqual(VwInsertDiffParaResponse.kidprFail, resp);
        }
Пример #30
0
        public void LargeTextScaling()
        {
            // Set up a ScripturePublication of 14 on 16 pts (base character size on line spacing).
            // (Original size is for 10 on 12).
            m_pub.BaseFontSize    = 14000;
            m_pub.BaseLineSpacing = -16000;
            DummyScripturePublication scrPub = DummyScripturePublication.Create(m_pub,
                                                                                TeViewType.Scripture | TeViewType.PrintLayout, m_realStylesheet);
            IVwStylesheet stylesheet    = scrPub.StyleSheet;
            ITsTextProps  ttpNormalPara = stylesheet.GetStyleRgch(0, ScrStyleNames.NormalParagraph);
            int           nVar;

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

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

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

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

            // We expect that these styles will be overridden for space before/after at 133% their original size.
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(48000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.MainBookTitle);
            Assert.AreEqual(16000, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(10667, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceBefore, out nVar));
            styleProps = stylesheet.GetStyleRgch(0, ScrStyleNames.SectionHead);
            Assert.AreEqual(5333, styleProps.GetIntPropValues((int)FwTextPropType.ktptSpaceAfter, out nVar));
        }
Пример #31
0
        public void SavingDeserializedAnnotationsToCache_WithHyperlink()
        {
            DateTime now    = DateTime.Now;
            DateTime utcNow = now.ToUniversalTime();

            XmlScrNote ann = CreateNote();

            ann.BeginScrRef        = "GEN 2:8";
            ann.ResolutionStatus   = NoteStatus.Closed;
            ann.AnnotationTypeGuid = CmAnnotationDefnTags.kguidAnnTranslatorNote.ToString();
            ann.DateTimeCreated    = utcNow.ToString(CultureInfo.InvariantCulture);
            ann.DateTimeModified   = utcNow.AddDays(1).ToString(CultureInfo.InvariantCulture);
            ann.DateTimeResolved   = utcNow.AddDays(2).ToString(CultureInfo.InvariantCulture);
            AddParasTo(ann.Discussion, "This is my", "discussion");
            AddParasTo(ann.Resolution, "This is my", "resolution for", "the note");
            AddParasTo(ann.Quote, "This is the", "quoted text");
            AddParasTo(ann.Suggestion, "This is", "my", "suggestion");
            AddHyperTo(ann.Suggestion[1], "http://www.tim.david.com/cooldudes.html");

            DummyXmlScrAnnotationsList list = new DummyXmlScrAnnotationsList();

            list.Annotations.Add(ann);

            list.CallWriteToCache(Cache, m_stylesheet);

            IScrBookAnnotations annotations = m_scr.BookAnnotationsOS[0];

            Assert.AreEqual(1, annotations.NotesOS.Count);

            IScrScriptureNote note = annotations.NotesOS[0];

            Assert.AreEqual(NoteType.Translator, note.AnnotationType);
            Assert.IsTrue(AreDateTimesClose(now, note.DateCreated));
            Assert.IsTrue(AreDatesClose(now.AddDays(1), note.DateModified));
            Assert.IsTrue(AreDatesClose(now.AddDays(2), note.DateResolved));

            TestAnnotationField(note.QuoteOA, "This is the", "quoted text");
            TestAnnotationField(note.DiscussionOA, "This is my", "discussion");
            TestAnnotationField(note.ResolutionOA, "This is my", "resolution for", "the note");
            TestAnnotationField(note.RecommendationOA, "This is", "mymy link", "suggestion");

            // Check the hyperlink location
            ITsTextProps props = ((IStTxtPara)note.RecommendationOA.ParagraphsOS[1]).Contents.get_Properties(1);
            string       href  = TsStringUtils.GetURL(props.GetStrPropValue((int)FwTextPropType.ktptObjData));

            Assert.AreEqual("http://www.tim.david.com/cooldudes.html", href);

            Assert.AreEqual(0, note.ResponsesOS.Count);
        }
Пример #32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Init writing system info and some props needed by some tests.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InitWsInfo()
		{
			Debug.Assert(m_cache != null);

			// get writing system info needed by tests
			m_wsVern = m_cache.DefaultVernWs;
			m_wsAnal = m_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();
		}
Пример #33
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Tests that the given run of the given ITsStrBldr contains the specified text
        /// and properties.
        /// </summary>
        /// <param name="iRun">zero-based run index</param>
        /// <param name="text">Expected run text</param>
        /// <param name="charStyleName">character style name, or null if expecting default
        /// paragraph character props</param>
        /// <param name="wsExpected">expected writing system for the run</param>
        /// <param name="strBldr">the string builder in which to verify the run</param>
        /// ------------------------------------------------------------------------------------
        protected void VerifyBldrRun(int iRun, string text, string charStyleName, int wsExpected,
                                     ITsStrBldr strBldr)
        {
            s_strBldr = strBldr;

            Assert.AreEqual(text, s_strBldr.get_RunText(iRun));
            ITsTextProps ttpExpected = CharStyleTextProps(charStyleName, wsExpected);
            ITsTextProps ttpRun      = s_strBldr.get_Properties(iRun);
            string       sWhy;

            if (!TsTextPropsHelper.PropsAreEqual(ttpExpected, ttpRun, out sWhy))
            {
                Assert.Fail(sWhy);
            }
        }
Пример #34
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Used by constructor.
        /// Sets the text property vars for this proxy, from the name, type, and ws
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SetTextProps()
        {
            if (m_Context == ContextValues.EndMarker || m_sStyleName == null || m_sStyleName == string.Empty)
            {                   // props are not relevant for end markers or markers with no style name
                m_ttpRunProps = m_ws == 0 ? null : StyleUtils.CharStyleTextProps(null, m_ws);
                return;
            }
            Debug.Assert(m_StyleType == StyleType.kstCharacter || m_StyleType == StyleType.kstParagraph);
            Debug.Assert(m_ws != 0);

            // For char style, the run props contain writing system & char style name; for para
            // style, they contain only the writing system.
            m_ttpRunProps = StyleUtils.CharStyleTextProps(
                (m_StyleType == StyleType.kstCharacter) ? m_sStyleName : null, m_ws);
        }
Пример #35
0
        /// <summary>
        /// This is a demonstration of one way to handle special tricks as the user types.
        /// This is an oversimplified way of forcing numbers to be treated as verse numbers...
        /// for example, it will cause '5000' in the 'feeding of the 5000' to be treated as a verse number.
        /// </summary>
        /// <param name="vwselNew"></param>
        protected override void HandleSelectionChange(IVwSelection vwselNew)
        {
            base.HandleSelectionChange(vwselNew);
            if (vwselNew == null)
            {
                return;                 // Not sure whether this happens, but best to be sure.
            }
            int       ichSel, hvoObj, tag, ws;
            bool      fAssocPrev;
            ITsString tss;

            vwselNew.TextSelInfo(false, out tss, out ichSel, out fAssocPrev, out hvoObj, out tag, out ws);

            string text = tss.get_Text();

            if (text == null)
            {
                return;                 // empty string.
            }
            ITsStrBldr tsb = null;

            for (int ich = 0; ich < text.Length; ++ich)
            {
                if (Char.IsDigit(text[ich]))
                {
                    ITsTextProps ttp       = tss.get_PropertiesAt(ich);
                    string       styleName = ttp.GetStrPropValue((int)FwKernelLib.FwTextPropType.ktptNamedStyle);
                    if (styleName != "verseNumber")
                    {
                        // We'll change just this one character. We could make this more efficient for dealing with
                        // long strings of digits, but it's unlikely we'll ever have to deal with more than one.
                        if (tsb == null)
                        {
                            tsb = tss.GetBldr();
                        }
                        tsb.SetStrPropValue(ich, ich + 1, (int)FwKernelLib.FwTextPropType.ktptNamedStyle, "verseNumber");
                    }
                }
            }
            if (tsb != null)
            {
                ISilDataAccess sda = m_rootb.get_DataAccess();
                // In this sample the only string is a multistring. If in doubt, we could test for ws == 0 to
                // see whether it is a simple string.
                sda.SetMultiStringAlt(hvoObj, tag, ws, tsb.GetString());
                sda.PropChanged(null, (int)FwViews.PropChangeType.kpctNotifyAll, hvoObj, tag, 0, tss.get_Length(), tss.get_Length());
            }
        }
Пример #36
0
        public void InsertFootnote()
        {
            CheckDisposed();
            FdoCache cache = m_firstMainWnd.Cache;

            // Set the IP to the second section in the first book at the 10th character in
            // the first paragraph
            m_firstDraftView.SetInsertionPoint(0, 1, 0, 10, false);
            ScrBook book       = (ScrBook)cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS[0];
            int     nFootnotes = book.FootnotesOS.Count;

            m_firstMainWnd.CallInsertFootnote();

            Assert.AreEqual(nFootnotes + 1, book.FootnotesOS.Count);

            // Test footnote
            string     expectedMarker = new String((char)((int)'a' + nFootnotes), 1);
            StFootnote footnote       = (StFootnote)book.FootnotesOS[nFootnotes];

            Assert.AreEqual(expectedMarker, footnote.FootnoteMarker.Text,
                            "Wrong footnote marker in footnote");
            ITsString    tsString  = footnote.FootnoteMarker.UnderlyingTsString;
            ITsTextProps ttp       = tsString.get_PropertiesAt(0);
            string       styleName = ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle);

            Assert.AreEqual(ScrStyleNames.FootnoteMarker, styleName,
                            "Wrong style for footnote marker in footnote");

            // Test footnote marker in text
            IVwSelection sel = m_firstDraftView.RootBox.Selection;
            ITsString    tss;
            int          ich, hvoObj, tag, enc;
            bool         fAssocPrev;

            sel.TextSelInfo(true, out tss, out ich, out fAssocPrev, out hvoObj, out tag, out enc);
            string strPara = tss.Text;

            Assert.AreEqual(StringUtils.kchObject, strPara[ich]);
            ttp = tss.get_PropertiesAt(ich);
            int nDummy;
            int wsActual = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out nDummy);

            Assert.AreEqual(cache.LangProject.DefaultVernacularWritingSystem, wsActual,
                            "Wrong writing system for footnote marker in text");
            string objData = ttp.GetStrPropValue((int)FwTextPropType.ktptObjData);

            Assert.AreEqual((char)(int)FwObjDataTypes.kodtOwnNameGuidHot, objData[0]);
        }
Пример #37
0
        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, 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 = TsPropsBldrClass.Create();
            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 tsf    = m_cache.TsStrFactory;
            var userWs = m_cache.DefaultUserWs;

            m_inputStr    = tsf.MakeString(MEStrings.ksMetaRuleInput, userWs);
            m_resultStr   = tsf.MakeString(MEStrings.ksMetaRuleResult, userWs);
            m_leftEnvStr  = tsf.MakeString(MEStrings.ksMetaRuleLeftEnv, userWs);
            m_rightEnvStr = tsf.MakeString(MEStrings.ksMetaRuleRightEnv, userWs);
            m_switchStr   = tsf.MakeString(MEStrings.ksMetaRuleSwitch, userWs);
        }
Пример #38
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Make one and hook it up to be called at the appropriate time.
		/// </summary>
		/// -----------------------------------------------------------------------------------
		public RequestSelectionHelper(IActionHandlerExtensions hookup, IVwRootBox rootb, int ihvoRoot,
			SelLevInfo[] rgvsli, int tagTextProp, int cpropPrevious, int ich, int wsAlt, bool fAssocPrev,
			ITsTextProps selProps)
		{
			m_hookup = hookup;
			m_rootb = rootb;
			m_ihvoRoot = ihvoRoot;
			m_rgvsli = rgvsli;
			m_tagTextProp = tagTextProp;
			m_cpropPrevious = cpropPrevious;
			m_ich = ich;
			m_wsAlt = wsAlt;
			m_fAssocPrev = fAssocPrev;
			m_selProps = selProps;
			m_hookup.DoAtEndOfPropChanged(m_hookup_PropChangedCompleted);
		}
Пример #39
0
		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, 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 = TsPropsBldrClass.Create();
			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 tsf = m_cache.TsStrFactory;
			var userWs = m_cache.DefaultUserWs;
			m_inputStr = tsf.MakeString(MEStrings.ksMetaRuleInput, userWs);
			m_resultStr = tsf.MakeString(MEStrings.ksMetaRuleResult, userWs);
			m_leftEnvStr = tsf.MakeString(MEStrings.ksMetaRuleLeftEnv, userWs);
			m_rightEnvStr = tsf.MakeString(MEStrings.ksMetaRuleRightEnv, userWs);
			m_switchStr = tsf.MakeString(MEStrings.ksMetaRuleSwitch, userWs);
		}
Пример #40
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);
		}
Пример #41
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 = (ITsPropsBldr)TsPropsBldrClass.Create();
			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();
		}
 public static List<string> ClassesFromTsTextProps(ITsTextProps props, int[] intPropsToSkip, int[] strPropsToSkip)
 {
     var classes = new List<string>();
     for (int i = 0, n = props.IntPropCount; i < n; i++)
     {
         int propNum;
         int variation;
         int propValue = props.GetIntProp(i, out propNum, out variation);
         if (intPropsToSkip.Contains(propNum))
             continue;
         string className = String.Format("propi_{0}_{1}_{2}_{3}", propNum, IntPropertyName(propNum), propValue, variation);
         classes.Add(className);
     }
     for (int i = 0, n = props.StrPropCount; i < n; i++)
     {
         int propNum;
         string propValue = props.GetStrProp(i, out propNum).Replace(" ", "_SPACE_");
         string className = String.Format("props_{0}_{1}_{2}", propNum, StringPropertyName(propNum), propValue);
         if (strPropsToSkip.Contains(propNum))
             continue;
         classes.Add(className);
     }
     return classes;
 }
Пример #43
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Checks to see if the text properties are for a hyperlink.
		/// </summary>
		/// <param name="ttp">The text properties.</param>
		/// <returns><c>true</c> if the properties are for a hyperlink; <c>false</c> otherwise.
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static bool IsHyperlink(ITsTextProps ttp)
		{
			string objData = ttp.ObjData();
			if (!String.IsNullOrEmpty(objData) && objData.Length > 1 && objData[0] == Convert.ToChar((int)FwObjDataTypes.kodtExternalPathName))
			{
				return true;
			}
			return false;
		}
Пример #44
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get a Guid from the given text props if the object type is a footnote or a picture.
		/// </summary>
		/// <param name="ttp">The text props</param>
		/// <returns>The GUID from the text props or Guid.Empty if the props do not contain
		/// a GUID or have a type of ORC that is not one of the desired kinds</returns>
		/// ------------------------------------------------------------------------------------
		public static Guid GetUsefulGuidFromProps(ITsTextProps ttp)
		{
			FwObjDataTypes odt;
			return GetGuidFromProps(ttp, s_footnoteAndPicObjectTypes, out odt);
		}
Пример #45
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get a Guid from the given text props.
		/// </summary>
		/// <param name="ttp">The text props</param>
		/// <param name="desiredOrcTypes">Set of ORC types that we're interested in, dude; or
		/// null if it don't make no difference</param>
		/// <param name="odt">Actual object type</param>
		/// <returns>The GUID from the text props or Guid.Empty if the props do not contain
		/// a GUID or have a type of ORC that is not one of the desired kinds</returns>
		/// ------------------------------------------------------------------------------------
		public static Guid GetGuidFromProps(ITsTextProps ttp, FwObjDataTypes[] desiredOrcTypes, out FwObjDataTypes odt)
		{
			odt = 0;
			string sObjData = ttp.ObjData();

			if (sObjData != null)
			{
				odt = (FwObjDataTypes)Convert.ToByte(sObjData[0]);
				// See if it's one of the types of objects we want.
				if (desiredOrcTypes == null || desiredOrcTypes.Contains(odt))
				{
					// Get GUID for ORC
					return MiscUtils.GetGuidFromObjData(sObjData.Substring(1));
				}
			}
			return Guid.Empty;
		}
Пример #46
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get a Guid from the given run in a structured text string.
		/// </summary>
		/// <param name="tss">given structured text string</param>
		/// <param name="iRun">given run</param>
		/// <param name="odt">object data type, 0 if no ORC guid located</param>
		/// <param name="tri">run information</param>
		/// <param name="ttp">text properties of the run (if incoming value is  null and the
		/// run is an object, this will be set to the run props)</param>
		/// <param name="desiredOrcTypes">The desired ORC types, or null to return any type of
		/// ORC</param>
		/// <returns>
		/// The GUID associated with the specified run of the tss, if any; otherwise Guid.Empty
		/// </returns>
		/// ------------------------------------------------------------------------------------
		private static Guid GetGuidFromRun(ITsString tss, int iRun, FwObjDataTypes[] desiredOrcTypes, out FwObjDataTypes odt, out TsRunInfo tri, ref ITsTextProps ttp)
		{
			tss.FetchRunInfo(iRun, out tri);
			if (tri.ichLim - tri.ichMin == 1 && tss.get_RunText(iRun)[0] == StringUtils.kChObject)
			{
				// determine if single-character run contains an ORC
				ttp = ttp ?? tss.get_Properties(iRun);
				return GetGuidFromProps(ttp, desiredOrcTypes, out odt);
			}
			odt = 0;
			return Guid.Empty;
		}
Пример #47
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get a "Hot" Guid from the given text props.
		/// </summary>
		/// <param name="ttp">The text props</param>
		/// <returns>The GUID from the text props or Guid.Empty if the props do not contain
		/// a GUID or have a non-hot ORC</returns>
		/// ------------------------------------------------------------------------------------
		public static Guid GetHotObjectGuidFromProps(ITsTextProps ttp)
		{
			FwObjDataTypes odt;
			return GetGuidFromProps(ttp, s_hotObjectTypes, out odt);
		}
Пример #48
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get a Guid from the given run in a structured text string.
		/// </summary>
		/// <param name="tss">given structured text string</param>
		/// <param name="iRun">given run</param>
		/// <param name="odt">object data type, 0 if no ORC guid located</param>
		/// <param name="tri">run information</param>
		/// <param name="ttp">text properties of the run</param>
		/// <param name="desiredOrcTypes">The desired ORC types, or null to return any type of
		/// ORC</param>
		/// <returns>
		/// The GUID associated with the specified run of the tss, if any; otherwise Guid.Empty
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static Guid GetGuidFromRun(ITsString tss, int iRun, out FwObjDataTypes odt, out TsRunInfo tri, out ITsTextProps ttp, FwObjDataTypes[] desiredOrcTypes)
		{
			ttp = null;
			return GetGuidFromRun(tss, iRun, desiredOrcTypes, out odt, out tri, ref ttp);
		}
Пример #49
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get a Guid from the given run in a structured text string.
		/// </summary>
		/// <param name="tss">given structured text string</param>
		/// <param name="iRun">given run</param>
		/// <param name="ttp">text properties of the run</param>
		/// <returns>
		/// The GUID associated with the specified run of the tss, if any; otherwise Guid.Empty
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static Guid GetGuidFromRun(ITsString tss, int iRun, ITsTextProps ttp)
		{
			FwObjDataTypes odt;
			TsRunInfo tri;
			return GetGuidFromRun(tss, iRun, null, out odt, out tri, ref ttp);
		}
		public void AllSelEndInfo(bool fEndPoint, out int _ihvoRoot, int cvlsi, ArrayPtr _rgvsli,
			out int _tagTextProp, out int _cpropPrevious, out int _ich, out int _ws,
			out bool _fAssocPrev, out ITsTextProps _pttp)
		{
			_ihvoRoot = 0;
			_tagTextProp = 0;
			_cpropPrevious = 0;
			if (fEndPoint)
				_ich = End;
			else
				_ich = Anchor;
			_ws = 0;
			_fAssocPrev = false;
			_pttp = null;
		}
Пример #51
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Used by constructor.
		/// Sets the text property vars for this proxy, from the name, type, and ws
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void SetTextProps()
		{
			if (m_Context == ContextValues.EndMarker || m_sStyleName == null || m_sStyleName == string.Empty)
			{	// props are not relevant for end markers or markers with no style name
				m_ttpRunProps = m_ws == 0 ? null : StyleUtils.CharStyleTextProps(null, m_ws);
				m_rgbParaProps = null;
				return;
			}
			Debug.Assert(m_StyleType == StyleType.kstCharacter || m_StyleType == StyleType.kstParagraph);
			Debug.Assert(m_ws != 0);

			// For char style, the run props contain writing system & char style name; for para
			// style, they contain only the writing system.
			m_ttpRunProps = StyleUtils.CharStyleTextProps(
				(m_StyleType == StyleType.kstCharacter) ? m_sStyleName : null, m_ws);

			// For char style, the paragraph props are empty; for para style, they contain the
			// para style name.
			if (m_StyleType == StyleType.kstParagraph)
			{
				ITsTextProps props = StyleUtils.ParaStyleTextProps(m_sStyleName);
				using (ArrayPtr rgbFmtBufPtr = MarshalEx.ArrayToNative<byte>(kcbFmtBufMax))
				{
					int nBytes = props.SerializeRgb(rgbFmtBufPtr, kcbFmtBufMax);
					m_rgbParaProps = MarshalEx.NativeToArray<byte>(rgbFmtBufPtr, nBytes);
				}
			}
			else
				m_rgbParaProps = null;
		}
Пример #52
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor with ContextValues and MarkerDomain as a parameters.
		/// </summary>
		/// <param name="sStyleName">Name of the style.</param>
		/// <param name="styleType">kstCharacter or kstParagraph</param>
		/// <param name="ws">character or paragraph writing system</param>
		/// <param name="context">Context that will be used if this is a new style (otherwise existing
		/// context in DB will be used), see ContextValues for possible types</param>
		/// <param name="domain">The marker domain to use</param>
		/// <param name="styleSheet">The style sheet</param>
		/// ------------------------------------------------------------------------------------
		public ImportStyleProxy(string sStyleName, StyleType styleType, int ws,
			ContextValues context, MarkerDomain domain, FwStyleSheet styleSheet)
		{
			m_FwStyleSheet = styleSheet;
			m_domain = domain;
			Debug.Assert(m_FwStyleSheet != null);

			m_ttpFormattingProps = null;
			m_fIsScriptureStyle = true; //default
			m_sEndMarker = null; //default

			if (context == ContextValues.EndMarker)
			{	// this proxy represents an end marker - not a style; set bogus info
				sStyleName = "End"; //name does not matter
				styleType = StyleType.kstCharacter;
			}
			else if (sStyleName != null)
			{
				// Determine whether style exists in the StyleSheet
				Debug.Assert(ws != 0);
				m_style = m_FwStyleSheet.FindStyle(sStyleName);
				if (m_style != null)
				{
					// If this is an existing style, the actual type, context, structure, and
					// function always override the requested values.
					styleType = m_style.Type;
					context = (ContextValues)m_style.Context;
					m_structure = (StructureValues)m_style.Structure;
					m_function = (FunctionValues)m_style.Function;
				}
			}

			m_sStyleName = sStyleName;
			m_StyleType = styleType;
			m_ws = ws;
			m_Context = context;

//			//force StartOfFootnote marker to be processed as a para style proxy having para props
//			if (context == StyleRole.StartOfFootnote)
//				m_StyleType = StyleType.kstParagraph;

			//set the text property vars for this proxy
			SetTextProps();
		}
Пример #53
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle insertion of paragraphs (i.e., from clipboard) with properties that don't
		/// match the properties of the paragraph where they are being inserted. This gives us
		/// the opportunity to create/modify the DB structure to recieve the paragraphs being
		/// inserted and to reject certain types of paste operations (such as attempting to
		/// paste a book).
		/// </summary>
		/// <param name="rootBox">the sender</param>
		/// <param name="ttpDest">properties of destination paragraph</param>
		/// <param name="cPara">number of paragraphs to be inserted</param>
		/// <param name="ttpSrcArray">Array of props of each para to be inserted</param>
		/// <param name="tssParas">Array of TsStrings for each para to be inserted</param>
		/// <param name="tssTrailing">Text of an incomplete paragraph to insert at end (with
		/// the properties of the destination paragraph.</param>
		/// <returns>One of the following:
		/// kidprDefault - causes the base implementation to insert the material as part of the
		/// current StText in the usual way;
		/// kidprFail - indicates that we have decided that this text should not be pasted at
		/// this location at all, causing entire operation to roll back;
		/// kidprDone - indicates that we have handled the paste ourselves, inserting the data
		/// wherever it ought to go and creating any necessary new structure.</returns>
		/// ------------------------------------------------------------------------------------
		public override VwInsertDiffParaResponse OnInsertDiffParas(IVwRootBox rootBox,
			ITsTextProps ttpDest, int cPara, ITsTextProps[] ttpSrcArray, ITsString[] tssParas,
			ITsString tssTrailing)
		{
			CheckDisposed();

			if (TeEditingHelper == null)
				return VwInsertDiffParaResponse.kidprFail;

			return TeEditingHelper.InsertDiffParas(rootBox, ttpDest, cPara, ttpSrcArray,
				tssParas, tssTrailing);
		}
		public void SetTypingProps(ITsTextProps _ttp)
		{
			throw new NotImplementedException();
		}
Пример #55
0
		/// <summary> see OnInsertDiffParas </summary>
		public override VwInsertDiffParaResponse OnInsertDiffPara(IVwRootBox rootBox,
			ITsTextProps ttpDest, ITsTextProps ttpSrc, ITsString tssParas,
			ITsString tssTrailing)
		{
			CheckDisposed();

			return OnInsertDiffParas(rootBox, ttpDest, 1, new ITsTextProps[] { ttpSrc },
				new ITsString[] { tssParas } , tssTrailing);

		}
Пример #56
0
		/// <summary>
		/// print root sites are never used for editing, so this routine should never be called.
		/// </summary>
		public void RequestSelectionAtEndOfUow(IVwRootBox _rootb, int ihvoRoot, int cvlsi,
			SelLevInfo[] rgvsli, int tagTextProp, int cpropPrevious, int ich, int wsAlt,
			bool fAssocPrev, ITsTextProps selProps)
		{
			throw new NotImplementedException();
		}
Пример #57
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the format vars for this potential style used when this is an undefined
		/// mapping, to prepare for possibly adding a real style
		/// </summary>
		/// <param name="tsTextPropsFormat">Formatting properties for this (potential) style
		/// </param>
		/// <param name="fIsScriptureStyle">true if style is used in Scripture; false otherwise
		/// </param>
		/// ------------------------------------------------------------------------------------
		public void SetFormat(ITsTextProps tsTextPropsFormat, bool fIsScriptureStyle)
		{
			Debug.Assert(tsTextPropsFormat != null);
			m_ttpFormattingProps = tsTextPropsFormat;
			m_fIsScriptureStyle = fIsScriptureStyle;
		}
Пример #58
0
		/// <summary> see OnInsertDiffParas </summary>
		VwInsertDiffParaResponse IVwRootSite.OnInsertDiffPara(IVwRootBox prootb,
			ITsTextProps ttpDest, ITsTextProps ttpSrc, ITsString tssParas,
			ITsString tssTrailing)
		{
			throw new NotImplementedException();
		}
Пример #59
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;
			}
		}
Пример #60
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get an owned Guid from the given run in a structured text string.
		/// </summary>
		/// <param name="tss">given structured text string</param>
		/// <param name="iRun">given run</param>
		/// <param name="odt">object data type, 0 if no owned guid located</param>
		/// <param name="tri">run information</param>
		/// <param name="ttp">text properties of the run</param>
		/// <returns>
		/// The GUID associated with the specified run of the tss if it is for an owned object;
		/// otherwise Guid.Empty
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static Guid GetOwnedGuidFromRun(ITsString tss, int iRun, out FwObjDataTypes odt, out TsRunInfo tri, out ITsTextProps ttp)
		{
			return GetGuidFromRun(tss, iRun, out odt, out tri, out ttp, s_ownedObjectTypes);
		}