Ejemplo n.º 1
0
        public void GetFootnoteMarkerFromGuid()
        {
            StFootnote footnote = new StFootnote();

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

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

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

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

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

            propsBldr.GetStrPropValue(1, out sObjData);

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

                Assert.AreEqual("2", footnoteMarker.Text);
            }
        }
Ejemplo n.º 2
0
		public void GetFootnoteMarkerFromGuid()
		{
			StFootnote footnote = new StFootnote();
			m_scr.ScriptureBooksOS[0].FootnotesOS.Append(footnote);
			footnote.FootnoteMarker.Text = "a";

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

			// Add the guid property so we can get it out as a string.
			ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
			byte[] objData = MiscUtils.GetObjData(guid, 1);
			propsBldr.SetStrPropValueRgch(1, objData, objData.Length);

			// Get the guid property as a string.
			string sObjData;
			propsBldr.GetStrPropValue(1, out sObjData);

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

				Assert.AreEqual("2", footnoteMarker.Text);
			}
		}
Ejemplo n.º 3
0
        public void GetFootnoteMarkerFromGuid()
        {
            IScrFootnote footnote = Cache.ServiceLocator.GetInstance <IScrFootnoteFactory>().Create();

            m_scr.ScriptureBooksOS[0].FootnotesOS.Add(footnote);
            footnote.FootnoteMarker = Cache.TsStrFactory.MakeString("a", Cache.WritingSystemFactory.GetWsFromStr("en"));

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

            byte[] objData = TsStringUtils.GetObjData(footnote.Guid, 1);
            propsBldr.SetStrPropValueRgch(1, objData, objData.Length);

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

            propsBldr.GetStrPropValue(1, out sObjData);

            StVc vc = new StVc(Cache.WritingSystemFactory.UserWs)
            {
                Cache = Cache
            };
            ITsString footnoteMarker = vc.GetStrForGuid(sObjData.Substring(1));

            // Call to GetStrForGuid doesn't generate a footnote marker based on the
            // Scripture Footnote properties since the method to do that is in TeStVc.
            int dummy;

            Assert.AreEqual(StringUtils.kszObject, footnoteMarker.Text);
            ITsTextProps props = footnoteMarker.get_Properties(0);

            Assert.AreEqual(2, props.IntPropCount);
            Assert.AreEqual(Cache.DefaultUserWs, props.GetIntPropValues((int)FwTextPropType.ktptWs, out dummy));
            Assert.AreEqual(0, props.GetIntPropValues((int)FwTextPropType.ktptEditable, out dummy));
            Assert.AreEqual(1, props.StrPropCount);

            FwObjDataTypes odt;
            Guid           footnoteGuid = TsStringUtils.GetGuidFromProps(props, null, out odt);

            Assert.IsTrue(odt == FwObjDataTypes.kodtPictEvenHot || odt == FwObjDataTypes.kodtPictOddHot);
            Assert.AreEqual(footnote.Guid, footnoteGuid);
        }
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Invoke the paragraph's style rule if any. The properties will apply to the next
        /// flow object--typically a paragraph, but in one TE case a picture--opened or added
        /// next.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="paraHvo">The HVO of the paragraph</param>
        /// <param name="vc">The view constructor</param>
        /// ------------------------------------------------------------------------------------
        protected static void ApplyParagraphStyleProps(IVwEnv vwenv, int paraHvo, StVc vc)
        {
            // Decide what style to apply to the paragraph.
            // Rules:
            //	1. Apply the paragraph's own style, or "Normal" if it has none.
            //	2. If the creator of the view constructor specified a default style
            //		and background color, invoke those as overrides.
            ITsTextProps tsTextProps = (ITsTextProps)vwenv.DataAccess.get_UnknownProp(paraHvo,
                                                                                      StParaTags.kflidStyleRules);

            if (vc.DefaultParaStyle.Length > 0)
            {
                vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle,
                                         vc.DefaultParaStyle);
                vwenv.set_IntProperty((int)FwTextPropType.ktptParaColor,
                                      (int)FwTextPropVar.ktpvDefault, vc.BackColor.ToArgb());
            }
            // The style the user has explicitly set on the paragraph should override the VC's default style.
            vwenv.Props = tsTextProps ?? vc.NormalStyle;
        }
Ejemplo n.º 5
0
            /// <summary>
            /// Executes in two distinct scenarios.
            ///
            /// 1. If disposing is true, the method has been called directly
            /// or indirectly by a user's code via the Dispose method.
            /// Both managed and unmanaged resources can be disposed.
            ///
            /// 2. If disposing is false, the method has been called by the
            /// runtime from inside the finalizer and you should not reference (access)
            /// other managed objects, as they already have been garbage collected.
            /// Only unmanaged resources can be disposed.
            /// </summary>
            /// <param name="disposing"></param>
            /// <remarks>
            /// If any exceptions are thrown, that is fine.
            /// If the method is being done in a finalizer, it will be ignored.
            /// If it is thrown by client code calling Dispose,
            /// it needs to be handled by fixing the bug.
            ///
            /// If subclasses override this method, they should call the base implementation.
            /// </remarks>
            protected override void Dispose(bool disposing)
            {
                //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
                // Must not be run more than once.
                if (IsDisposed)
                {
                    return;
                }

                if (disposing)
                {
                    // Dispose managed resources here.
                    if (m_stvc != null)
                    {
                        m_stvc.Dispose();
                    }
                }

                // Dispose unmanaged resources here, whether disposing is true or false.
                m_stvc = null;

                base.Dispose(disposing);
            }
Ejemplo n.º 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Invoke the paragraph's style rule if any. The properties will apply to the next
        /// flow object--typically a paragraph, but in one TE case a picture--opened or added
        /// next.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="vc">The view constructor</param>
        /// ------------------------------------------------------------------------------------
        protected static void ApplyParagraphStyleProps(IVwEnv vwenv, int hvo, StVc vc)
        {
            ITsTextProps tsTextProps = (ITsTextProps)vwenv.DataAccess.get_UnknownProp(hvo,
                                                                                      (int)StPara.StParaTags.kflidStyleRules);

            // Decide what style to apply to the paragraph.
            // Rules:
            //	1. Apply the paragraph's own style, or "Normal" if it has none.
            //	2. If the creator of the view constructor specified a default style
            //		and background color, invoke those as overrides.
            if (tsTextProps == null)
            {
                // Client didn't spec, and nothing on the para, default to normal.
                tsTextProps = vc.NormalStyle;
            }
            vwenv.Props = tsTextProps;
            if (vc.DefaultParaStyle.Length > 0)
            {
                vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle,
                                         vc.DefaultParaStyle);
                vwenv.set_IntProperty((int)FwTextPropType.ktptParaColor,
                                      (int)FwTextPropVar.ktpvDefault, vc.BackColor.ToArgb());
            }
        }
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();

			m_vc = new StVc();
			m_vc.Cache = Cache;

			m_pattern = VwPatternClass.Create();
			m_strFactory = TsStrFactoryClass.Create();

			m_pattern.Pattern = m_strFactory.MakeString("a", Cache.DefaultVernWs);
			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
		}
Ejemplo n.º 8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Insert the body of a paragraph. This is normally (with fApplyProps true) the body
		/// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses
		/// need to separate this from applying the properties.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="paraHvo"></param>
		/// <param name="frag"></param>
		/// <param name="fApplyProps"></param>
		/// <param name="contentType"></param>
		/// <param name="vc">The view constructor used to create the paragraphs</param>
		/// ------------------------------------------------------------------------------------
		protected void InsertParagraphBody(IVwEnv vwenv, int paraHvo, int frag, bool fApplyProps,
			ContentTypes contentType, StVc vc)
		{
			vc.SetupWsAndDirectionForPara(vwenv, paraHvo);

			if (fApplyProps)
				ApplyParagraphStyleProps(vwenv, paraHvo, vc);

			// This was causing assertions in the layoutmgr
			// TODO (TE-5777): Should be able to do this with an in-memory stylesheet.
			//			if (DisplayTranslation)
			//			{
			//				// display the back translation text as double spaced
			//				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight,
			//					(int)FwTextPropVar.ktpvRelative, 20000);
			//			}
			// The body of the paragraph is either editable or not.
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
				vc.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
			// Make the paragraph containing the paragraph contents.
			OpenPara(vwenv, paraHvo);
			// Cause a regenerate when the style changes...this is mainly used for Undo.
			vwenv.NoteDependency(new[] {paraHvo}, new[] {StParaTags.kflidStyleRules}, 1);
			// Insert the label if it is the first paragraph.
			if (vc.Label != null)
			{
				int lev = vwenv.EmbeddingLevel;
				int hvoOuter;
				int ihvoItem;
				int tagOuter;
				vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
				if (ihvoItem == 0)
					vwenv.AddObj(paraHvo, vc, (int)StTextFrags.kfrLabel);
			}
			if (frag == (int)StTextFrags.kfrFootnotePara)
			{
				int lev = vwenv.EmbeddingLevel;
				int hvoOuter;
				int ihvoItem;
				int tagOuter;
				vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
				// Note a dependency on the footnote options so that the footnote will
				// be refreshed when these are changed.
				// If this is the 1st paragraph in the footnote...
				if (ihvoItem == 0)
				{
					vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker);
					vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteReference);
				}
			}

			if (contentType == ContentTypes.kctSimpleBT)
			{
				// If a translation is being shown instead of the paragraph, then show it instead
				// of the text of the paragraph.
				vwenv.AddObj(GetTranslationForPara(paraHvo), vc, (int)StTextFrags.kfrTranslation);
				if (!PrintLayout)
				{
					// This dependency is here so that the "Missing" prompt will be added to the
					// view when the first character is typed in the contents. But to solve the
					// problem with losing the IP when typing (FWR-1415), the dependency is not
					// added in print layout views. The missing prompt seems less of a problem
					// than the problem with typing.
					vwenv.NoteDependency(new[]{paraHvo}, new[]{StTxtParaTags.kflidContents}, 1);
				}
			}
			else if (contentType == ContentTypes.kctSegmentBT)
			{
				vwenv.AddObjVecItems(StTxtParaTags.kflidSegments, vc, (int)StTextFrags.kfrSegmentFreeTranslations);
			}
			else if (!InsertParaContentsUserPrompt(vwenv, paraHvo))
			{
				// Display the text paragraph contents, or its user prompt.
				vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
			}

			// Display an "end-of-paragraph" marker if needed
			InsertEndOfParaMarks(vwenv, paraHvo);

			vwenv.CloseParagraph();
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <remarks>This method is called after each test</remarks>
		/// ------------------------------------------------------------------------------------
		public override void TestTearDown()
		{
			m_vc = null;
			m_section = null;
			m_para1 = null;
			m_para2 = null;
			m_para3 = null;
			if (Marshal.IsComObject(m_pattern))
				Marshal.ReleaseComObject(m_pattern);
			m_pattern = null;
			if (Marshal.IsComObject(m_strFactory))
				Marshal.ReleaseComObject(m_strFactory);
			m_strFactory = null;


			base.TestTearDown();
		}
Ejemplo n.º 10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Invoke the paragraph's style rule if any. The properties will apply to the next
		/// flow object--typically a paragraph, but in one TE case a picture--opened or added
		/// next.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="vc">The view constructor</param>
		/// ------------------------------------------------------------------------------------
		protected static void ApplyParagraphStyleProps(IVwEnv vwenv, int hvo, StVc vc)
		{
			ITsTextProps tsTextProps = (ITsTextProps)vwenv.DataAccess.get_UnknownProp(hvo,
				(int)StPara.StParaTags.kflidStyleRules);

			// Decide what style to apply to the paragraph.
			// Rules:
			//	1. Apply the paragraph's own style, or "Normal" if it has none.
			//	2. If the creator of the view constructor specified a default style
			//		and background color, invoke those as overrides.
			if (tsTextProps == null)
			{
				// Client didn't spec, and nothing on the para, default to normal.
				tsTextProps = vc.NormalStyle;
			}
			vwenv.Props = tsTextProps;
			if (vc.DefaultParaStyle.Length > 0)
			{
				vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle,
					vc.DefaultParaStyle);
				vwenv.set_IntProperty((int)FwTextPropType.ktptParaColor,
					(int)FwTextPropVar.ktpvDefault, vc.BackColor.ToArgb());
			}
		}
Ejemplo n.º 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the index of the level for the given tag.
		/// </summary>
		/// <param name="tag">The tag.</param>
		/// <param name="contentType">Kind of selection for which to adjust level</param>
		/// <returns>Index of the level, or -1 if unknown level.</returns>
		/// ------------------------------------------------------------------------------------
		public static int GetLevelIndexForTag(int tag, StVc.ContentTypes contentType)
		{
			int levelIndex;
			switch (tag)
			{
				case CmPictureTags.kflidCaption:
					return 0;
				case StTxtParaTags.kflidTranslations:
					return 0; // always 0 (except when in a BT of a picture caption)
				case StTextTags.kflidParagraphs:
					levelIndex = 0;
					break;
				case ScrSectionTags.kflidHeading:
				case ScrSectionTags.kflidContent:
				case ScrBookTags.kflidTitle:
				case ScrBookTags.kflidFootnotes:
					levelIndex = 1;
					break;
				case ScrBookTags.kflidSections:
					levelIndex = 2;
					break;
				case ScriptureTags.kflidScriptureBooks:
					levelIndex = 3;
					break;
				default:
					Debug.Fail("Invalid tag in GetLevelIndexForTag");
					return -1;
			}

			return levelIndex + LevelOffset(contentType);
		}
Ejemplo n.º 12
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the FootnoteVc class
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public DummyFootnoteVc(FdoCache cache)
 {
     m_stvc           = new StVc();
     m_stvc.Cache     = cache;
     m_stvc.DefaultWs = cache.LanguageWritingSystemFactoryAccessor.UserWs;
 }
Ejemplo n.º 13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the number of levels for the given tag.
		/// </summary>
		/// <param name="tag">The tag.</param>
		/// <param name="contentType">The kind of selection to return info about</param>
		/// <returns>Number of levels</returns>
		/// ------------------------------------------------------------------------------------
		public static int GetLevelCountForTag(int tag, StVc.ContentTypes contentType)
		{
			int levelCount;
			switch (tag)
			{
				case ScrBookTags.kflidTitle:
					levelCount = kBookTitleLevelCount;
					break;
				case ScrSectionTags.kflidHeading:
				case ScrSectionTags.kflidContent:
					levelCount = kSectionLevelCount;
					break;
				case ScrBookTags.kflidFootnotes:
					levelCount = kFootnoteLevelCount;
					break;
				default:
					Debug.Fail("Invalid tag in GetLevelCountForTag");
					return -1;
			}

			return levelCount + LevelOffset(contentType);
		}
Ejemplo n.º 14
0
			/// <summary>
			/// Executes in two distinct scenarios.
			///
			/// 1. If disposing is true, the method has been called directly
			/// or indirectly by a user's code via the Dispose method.
			/// Both managed and unmanaged resources can be disposed.
			///
			/// 2. If disposing is false, the method has been called by the
			/// runtime from inside the finalizer and you should not reference (access)
			/// other managed objects, as they already have been garbage collected.
			/// Only unmanaged resources can be disposed.
			/// </summary>
			/// <param name="disposing"></param>
			/// <remarks>
			/// If any exceptions are thrown, that is fine.
			/// If the method is being done in a finalizer, it will be ignored.
			/// If it is thrown by client code calling Dispose,
			/// it needs to be handled by fixing the bug.
			///
			/// If subclasses override this method, they should call the base implementation.
			/// </remarks>
			protected override void Dispose(bool disposing)
			{
				//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
				// Must not be run more than once.
				if (IsDisposed)
					return;

				if (disposing)
				{
					// Dispose managed resources here.
					if (m_stvc != null)
						m_stvc.Dispose();
				}

				// Dispose unmanaged resources here, whether disposing is true or false.
				m_stvc = null;

				base.Dispose(disposing);
			}
Ejemplo n.º 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="LocationTrackerImpl"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="filterInstance">The filter instance. If 0, then the normal DB book list
		/// is used</param>
		/// <param name="contentType">Indicates the kind of data in the view about which we
		/// are returning selection information.</param>
		/// ------------------------------------------------------------------------------------
		public LocationTrackerImpl(FdoCache cache, int filterInstance, StVc.ContentTypes contentType)
		{
			m_cache = cache;
			m_bookFilter = cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(filterInstance);
			m_contentType = contentType;
		}
Ejemplo n.º 16
0
		public override void MakeRoot()
		{
			CheckDisposed();

			if (m_fdoCache == null || DesignMode || m_slice.ContainingDataTree == null)
				return;

			m_rootb = VwRootBoxClass.Create();
			m_rootb.SetSite(this);
			if (m_ws == 0)
				m_ws = m_fdoCache.DefaultAnalWs;

			m_hvoStText = m_fdoCache.GetObjProperty(m_hvoOwner, m_flid);
			// If we don't already have an StText in this field, make one now.
			if (m_hvoStText == 0)
			{
				ISilDataAccess sda = m_fdoCache.MainCacheAccessor;
				// Create one and initialize it. Don't use the FdoCache method, because it's important NOT to notify
				// our own data tree of the change...if we do, it could start a new regenerate in the middle of an
				// existing one with bad consequences.
				m_hvoStText = sda.MakeNewObject(StText.kclsidStText, m_hvoOwner, m_flid, -2);
				int hvoStTxtPara = sda.MakeNewObject(StTxtPara.kclsidStTxtPara, m_hvoStText, (int)StText.StTextTags.kflidParagraphs, 0);
				ITsStrFactory tsf = TsStrFactoryClass.Create();
				sda.SetString(hvoStTxtPara, (int) StTxtPara.StTxtParaTags.kflidContents, tsf.MakeString("", m_ws));
				// Notify change on the main property. The other properties we changed are part of the new object, and nothing
				// can know their previous state and need to see the change.
				sda.PropChanged(m_slice.ContainingDataTree, (int)PropChangeType.kpctNotifyAllButMe, m_hvoOwner, m_flid, 0, 1, 0);
			}

			m_vc = new StVc("Normal", m_ws);
			m_vc.Cache = m_fdoCache;
			m_vc.Editable = true;

			m_rootb.DataAccess = m_fdoCache.MainCacheAccessor;

			m_rootb.SetRootObject(m_hvoStText, m_vc, (int)StTextFrags.kfrText,
				m_styleSheet);

			base.MakeRoot();
			m_dxdLayoutWidth = kForceLayout; // Don't try to draw until we get OnSize and do layout.

			//TODO:
			//ptmw->RegisterRootBox(qrootb);
		}
Ejemplo n.º 17
0
			/// ------------------------------------------------------------------------------------
			/// <summary>
			/// Initializes a new instance of the FootnoteVc class
			/// </summary>
			/// ------------------------------------------------------------------------------------
			public DummyFootnoteVc(FdoCache cache)
			{
				m_stvc = new StVc();
				m_stvc.Cache = cache;
				m_stvc.DefaultWs = cache.LanguageWritingSystemFactoryAccessor.UserWs;
			}
Ejemplo n.º 18
0
		/// <summary>
		/// We override this to check that segments are properly loaded. Normally this is done by LoadDataForStText
		/// when the containing section (the smallest lazy element) is loaded, but that doesn't run when we insert a paragraph.
		/// </summary>
		protected override void InsertBtSegments(StVc vc, IVwEnv vwenv, int hvo)
		{
			int kflidSegments = StTxtPara.SegmentsFlid(Cache);
			if (!Cache.MainCacheAccessor.get_IsPropInCache(hvo, kflidSegments, (int)CellarModuleDefns.kcptReferenceSequence, 0))
			{
				StTxtPara para = CmObject.CreateFromDBObject(Cache, hvo) as StTxtPara;
				ParagraphParserOptions options = new ParagraphParserOptions();
				options.CreateRealSegments = true;
				ParagraphParser.ParseParagraph(para, options);
				StTxtPara.LoadSegmentFreeTranslations(new int[] {hvo}, Cache, BackTranslationWS);
				// This is probably redundant, AFAIK this can only happen for newly created paragraphs,
				// but it's safe and (for the same reason) rare.
				if (para.HasNoSegmentBt(BackTranslationWS))
					ConvertOldBtToNew(para);
			}
			base.InsertBtSegments(vc, vwenv, hvo);
		}
Ejemplo n.º 19
0
		/// <summary>
		/// Insert the back translation segments. TeStVc overrides to make sure they are loaded properly.
		/// </summary>
		protected virtual void InsertBtSegments(StVc vc, IVwEnv vwenv, int hvo)
		{
			vwenv.AddObjVecItems(StTxtPara.SegmentsFlid(Cache), vc, (int)StTextFrags.kfrSegmentFreeTranslations);
		}
Ejemplo n.º 20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Insert the body of a paragraph. This is normally (with fApplyProps true) the body
		/// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses
		/// need to separate this from applying the properties.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		/// <param name="frag"></param>
		/// <param name="fApplyProps"></param>
		/// <param name="contentType"></param>
		/// <param name="vc">The view constructor used to create the paragraphs</param>
		/// ------------------------------------------------------------------------------------
		protected void InsertParagraphBody(IVwEnv vwenv, int hvo, int frag, bool fApplyProps,
			ContentTypes contentType, StVc vc)
		{
			vc.SetupWsAndDirectionForPara(vwenv, hvo);

			if (fApplyProps)
				ApplyParagraphStyleProps(vwenv, hvo, vc);

			// This was causing assertions in the layoutmgr
			// TODO (TE-5777): Should be able to do this with an in-memory stylesheet.
			//			if (DisplayTranslation)
			//			{
			//				// display the back translation text as double spaced
			//				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight,
			//					(int)FwTextPropVar.ktpvRelative, 20000);
			//			}
			// The body of the paragraph is either editable or not.
			vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
				(int)FwTextPropVar.ktpvEnum,
				vc.Editable ? (int)TptEditable.ktptIsEditable
				: (int)TptEditable.ktptNotEditable);
			// Make the paragraph containing the paragraph contents.
			OpenPara(vwenv, hvo);
			// Cause a regenerate when the style changes...this is mainly used for Undo.
			vwenv.NoteDependency(new int[] {hvo},
				new int[] {(int)StPara.StParaTags.kflidStyleRules}, 1);
			// Insert the label if it is the first paragraph.
			if (vc.Label != null)
			{
				int lev = vwenv.EmbeddingLevel;
				int hvoOuter;
				int ihvoItem;
				int tagOuter;
				vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
				if (ihvoItem == 0)
					vwenv.AddObj(hvo, vc, (int)StTextFrags.kfrLabel);
			}
			if (frag == (int)StTextFrags.kfrFootnotePara)
			{
				int lev = vwenv.EmbeddingLevel;
				int hvoOuter;
				int ihvoItem;
				int tagOuter;
				vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
				// Note a dependency on the footnote options so that the footnote will
				// be refreshed when these are changed.
				int[] depHvos = { hvoOuter };
				int[] depTags = { StFootnote.ktagFootnoteOptions };
				vwenv.NoteDependency(depHvos, depTags, 1);
				// If this is the 0th paragraph in the footnote...
				if (ihvoItem == 0)
				{
					vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker);
					vwenv.AddObj(hvoOuter, /*vc.Parent != null ? vc.Parent :*/ vc,
						(int)StTextFrags.kfrFootnoteReference);
				}
			}

			if (contentType == ContentTypes.kctSimpleBT)
			{
				// If a translation is being shown instead of the paragraph, then show it instead
				// of the text of the paragraph.
				int transHvo = GetTranslationForPara(hvo);
				vwenv.AddObj(transHvo, vc, (int)StTextFrags.kfrTranslation);
				vwenv.NoteDependency(new int[] {hvo},
					new int[] {(int)StTxtPara.StTxtParaTags.kflidContents}, 1);
			}
			else if (contentType == ContentTypes.kctSegmentBT)
			{
				InsertBtSegments(vc, vwenv, hvo);
			}
			else if (!InsertParaContentsUserPrompt(vwenv, hvo))
			{
				// Display the text paragraph contents, or its user prompt.
				vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null);
			}

			// Display an "end-of-paragraph" marker if needed
			InsertEndOfParaMarks(vwenv, hvo);

			vwenv.CloseParagraph();
		}
		public override void Exit()
		{
			CheckDisposed();

			m_vc.Dispose();
			m_vc = null;
			m_section = null;
			m_para1 = null;
			m_para2 = null;
			m_para3 = null;
			if (Marshal.IsComObject(m_pattern))
				Marshal.ReleaseComObject(m_pattern);
			m_pattern = null;
			if (Marshal.IsComObject(m_strFactory))
				Marshal.ReleaseComObject(m_strFactory);
			m_strFactory = null;

			base.Exit();
		}
Ejemplo n.º 22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates and returns the primary view construtor for the main view in the layout.
		/// This is only called once.
		/// </summary>
		/// <returns>The view constructor to be used for the main view</returns>
		/// ------------------------------------------------------------------------------------
		public virtual IVwViewConstructor MakeMainVc(DivisionLayoutMgr div)
		{
			StVc vc = new StVc();
			vc.Cache = m_fdoCache;
			return vc;
		}
		public void ReplaceAllWithReadOnly()
		{
			CheckDisposed();

			if (m_vc != null)
				m_vc.Dispose();
			m_vc = new DummyScriptureVc(m_para1.Hvo);
			m_vc.Cache = Cache;
			m_pattern.ReplaceWith = m_strFactory.MakeString("b", Cache.DefaultVernWs);

			ReplaceAllCollectorEnv collectorEnv = new ReplaceAllCollectorEnv(m_vc,
				Cache.MainCacheAccessor, m_para1.OwnerHVO, (int)StTextFrags.kfrText,
				m_pattern, null);
			int nReplaces = collectorEnv.ReplaceAll();

			Assert.AreEqual(5, nReplaces);
			Assert.AreEqual("This is some text so that we can test the find functionality.",
				m_para1.Contents.Text);
			Assert.AreEqual("Some more text so thbt we cbn test the find bnd replbce functionblity.",
				m_para2.Contents.Text);
			Assert.AreEqual("This purugruph doesn't contuin the first letter of the ulphubet.",
				m_para3.Contents.Text);
		}
Ejemplo n.º 24
0
		public void Init(Mediator mediator, IStText text, int ws)
		{
			CheckDisposed();
			Mediator = mediator;
			Cache = (FdoCache)mediator.PropertyTable.GetValue("cache");
			StyleSheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
			m_text = text;
			m_vc = new StVc("Normal", ws) {Cache = m_fdoCache, Editable = true};
			DoSpellCheck = true;
			if (m_rootb == null)
			{
				MakeRoot();
			}
			else if (m_text != null)
			{
				m_rootb.SetRootObject(m_text.Hvo, m_vc, (int)StTextFrags.kfrText, m_styleSheet);
				m_rootb.Reconstruct();
			}
		}
Ejemplo n.º 25
0
		static int LevelOffset(StVc.ContentTypes contentType)
		{
			switch (contentType)
			{
				case StVc.ContentTypes.kctSimpleBT:
					// Selection is in Translation of CmTranslation in Translations of StTxtPara (in StText...)
					return 1;
				case StVc.ContentTypes.kctSegmentBT:
					// Selection is in FreeTranslation of Segment in StTxtPara (in StText...)
					return 1;
				default: // StVc.ContentTypes.kctNormal
					// Selection is in contents of StTxtPara (in StText in Contents or Heading of ScrSection in ...)
					return 0;
			}
		}
Ejemplo n.º 26
0
		public void GetFootnoteMarkerFromGuid()
		{
			IScrFootnote footnote = Cache.ServiceLocator.GetInstance<IScrFootnoteFactory>().Create();
			m_scr.ScriptureBooksOS[0].FootnotesOS.Add(footnote);
			footnote.FootnoteMarker = Cache.TsStrFactory.MakeString("a", Cache.WritingSystemFactory.GetWsFromStr("en"));

			// Add the guid property so we can get it out as a string.
			ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
			byte[] objData = TsStringUtils.GetObjData(footnote.Guid, 1);
			propsBldr.SetStrPropValueRgch(1, objData, objData.Length);

			// Get the guid property as a string.
			string sObjData;
			propsBldr.GetStrPropValue(1, out sObjData);

			StVc vc = new StVc(Cache.WritingSystemFactory.UserWs) { Cache = Cache };
			ITsString footnoteMarker = vc.GetStrForGuid(sObjData.Substring(1));

			// Call to GetStrForGuid doesn't generate a footnote marker based on the
			// Scripture Footnote properties since the method to do that is in TeStVc.
			int dummy;
			Assert.AreEqual(StringUtils.kszObject, footnoteMarker.Text);
			ITsTextProps props = footnoteMarker.get_Properties(0);
			Assert.AreEqual(2, props.IntPropCount);
			Assert.AreEqual(Cache.DefaultUserWs, props.GetIntPropValues((int)FwTextPropType.ktptWs, out dummy));
			Assert.AreEqual(0, props.GetIntPropValues((int)FwTextPropType.ktptEditable, out dummy));
			Assert.AreEqual(1, props.StrPropCount);

			FwObjDataTypes odt;
			Guid footnoteGuid = TsStringUtils.GetGuidFromProps(props, null, out odt);
			Assert.IsTrue(odt == FwObjDataTypes.kodtPictEvenHot || odt == FwObjDataTypes.kodtPictOddHot);
			Assert.AreEqual(footnote.Guid, footnoteGuid);
		}
Ejemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the DummyBasicViewVc class
 /// </summary>
 public DummyDraftViewVc()
 {
     m_stvc = new StVc();
 }
Ejemplo n.º 28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the DraftView class as a draft view editing pane,
		/// for either vernacular or back translation.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="contentType">specifies normal or some kind of BT</param>
		/// <param name="showInTable">True to show the text layed out in a table, false
		/// otherwise</param>
		/// <param name="makeRootAutomatically">attempt to construct the rootbox automatically
		/// when the window handle is created</param>
		/// <param name="persistSettings">true to save and load settings for the window</param>
		/// <param name="viewType">Type of the view.</param>
		/// <param name="filterInstance"></param>
		/// ------------------------------------------------------------------------------------
		public DraftView(FdoCache cache, StVc.ContentTypes contentType, bool showInTable,
			bool makeRootAutomatically, bool persistSettings, TeViewType viewType,
			int filterInstance) : base(cache)
		{
			if (contentType == StVc.ContentTypes.kctSegmentBT)
				LexEntryUi.EnsureFlexVirtuals(Cache, Mediator);

			AutoScroll = false;
			m_contentType = contentType;
			m_fShowInTable = showInTable;
			m_fMakeRootWhenHandleIsCreated = makeRootAutomatically;
			m_persistSettings = persistSettings;
			m_filterInstance = filterInstance;

			m_bookFilter = FilteredScrBooks.GetFilterInstance(cache, m_filterInstance);
			// if the filter is still null then make one for testing
			if (m_bookFilter == null && TheMainWnd == null)
				m_bookFilter = new FilteredScrBooks(cache, m_filterInstance);

			m_locationTracker = new LocationTrackerImpl(cache, m_filterInstance,
				m_contentType);

			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			BackColor = EditableColor;
			m_viewType = viewType;
			DoSpellCheck = (EditingHelper as TeEditingHelper).ShowSpellingErrors;
		}
Ejemplo n.º 29
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the FootnoteVc class
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public DummyFootnoteVc(FdoCache cache) : base(cache.WritingSystemFactory.UserWs)
 {
     m_stvc       = new StVc(cache.WritingSystemFactory.UserWs);
     m_stvc.Cache = cache;
 }
Ejemplo n.º 30
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void MakeRoot()
		{
			CheckDisposed();

			if (m_sda == null || DesignMode)
				return;

			if (m_rootb == null)
				m_rootb = VwRootBoxClass.Create();

			m_rootb.SetSite(this);
			HorizMargin = 5;

			// Set up a new view constructor.
			m_vc = new StVc(CurrentWs);
			m_vc.Editable = true;
			m_vc.BackColor = BackColor;
			m_rootb.DataAccess = m_sda;
			m_rootb.SetRootObject(kMemTextHvo, m_vc, (int)StTextFrags.kfrText, m_styleSheet);

			base.MakeRoot();
			m_dxdLayoutWidth = kForceLayout;
		}
Ejemplo n.º 31
0
 /// <summary>
 /// Initializes a new instance of the DummyBasicViewVc class
 /// </summary>
 public DummyDraftViewVc()
 {
     m_stvc = new StVc();
 }
Ejemplo n.º 32
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert the body of a paragraph. This is normally (with fApplyProps true) the body
        /// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses
        /// need to separate this from applying the properties.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// <param name="fApplyProps"></param>
        /// <param name="contentType"></param>
        /// <param name="vc">The view constructor used to create the paragraphs</param>
        /// ------------------------------------------------------------------------------------
        protected void InsertParagraphBody(IVwEnv vwenv, int hvo, int frag, bool fApplyProps,
                                           ContentTypes contentType, StVc vc)
        {
            vc.SetupWsAndDirectionForPara(vwenv, hvo);

            if (fApplyProps)
            {
                ApplyParagraphStyleProps(vwenv, hvo, vc);
            }

            // This was causing assertions in the layoutmgr
            // TODO (TE-5777): Should be able to do this with an in-memory stylesheet.
            //			if (DisplayTranslation)
            //			{
            //				// display the back translation text as double spaced
            //				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight,
            //					(int)FwTextPropVar.ktpvRelative, 20000);
            //			}
            // The body of the paragraph is either editable or not.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable,
                                  (int)FwTextPropVar.ktpvEnum,
                                  vc.Editable ? (int)TptEditable.ktptIsEditable
                                : (int)TptEditable.ktptNotEditable);
            // Make the paragraph containing the paragraph contents.
            OpenPara(vwenv, hvo);
            // Cause a regenerate when the style changes...this is mainly used for Undo.
            vwenv.NoteDependency(new int[] { hvo },
                                 new int[] { (int)StPara.StParaTags.kflidStyleRules }, 1);
            // Insert the label if it is the first paragraph.
            if (vc.Label != null)
            {
                int lev = vwenv.EmbeddingLevel;
                int hvoOuter;
                int ihvoItem;
                int tagOuter;
                vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
                if (ihvoItem == 0)
                {
                    vwenv.AddObj(hvo, vc, (int)StTextFrags.kfrLabel);
                }
            }
            if (frag == (int)StTextFrags.kfrFootnotePara)
            {
                int lev = vwenv.EmbeddingLevel;
                int hvoOuter;
                int ihvoItem;
                int tagOuter;
                vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
                // Note a dependency on the footnote options so that the footnote will
                // be refreshed when these are changed.
                int[] depHvos = { hvoOuter };
                int[] depTags = { StFootnote.ktagFootnoteOptions };
                vwenv.NoteDependency(depHvos, depTags, 1);
                // If this is the 0th paragraph in the footnote...
                if (ihvoItem == 0)
                {
                    vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker);
                    vwenv.AddObj(hvoOuter, /*vc.Parent != null ? vc.Parent :*/ vc,
                                 (int)StTextFrags.kfrFootnoteReference);
                }
            }

            if (contentType == ContentTypes.kctSimpleBT)
            {
                // If a translation is being shown instead of the paragraph, then show it instead
                // of the text of the paragraph.
                int transHvo = GetTranslationForPara(hvo);
                vwenv.AddObj(transHvo, vc, (int)StTextFrags.kfrTranslation);
                vwenv.NoteDependency(new int[] { hvo },
                                     new int[] { (int)StTxtPara.StTxtParaTags.kflidContents }, 1);
            }
            else if (contentType == ContentTypes.kctSegmentBT)
            {
                InsertBtSegments(vc, vwenv, hvo);
            }
            else if (!InsertParaContentsUserPrompt(vwenv, hvo))
            {
                // Display the text paragraph contents, or its user prompt.
                vwenv.AddStringProp((int)StTxtPara.StTxtParaTags.kflidContents, null);
            }

            // Display an "end-of-paragraph" marker if needed
            InsertEndOfParaMarks(vwenv, hvo);

            vwenv.CloseParagraph();
        }
Ejemplo n.º 33
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			// Must not be run more than once.
			if (IsDisposed)
				return;

			base.Dispose(disposing);

			if (disposing)
			{
				// Dispose managed resources here.
			}
			m_vc = null;

			// Dispose unmanaged resources here, whether disposing is true or false.
		}
Ejemplo n.º 34
0
 /// <summary>
 /// Insert the back translation segments. TeStVc overrides to make sure they are loaded properly.
 /// </summary>
 protected virtual void InsertBtSegments(StVc vc, IVwEnv vwenv, int hvo)
 {
     vwenv.AddObjVecItems(StTxtPara.SegmentsFlid(Cache), vc, (int)StTextFrags.kfrSegmentFreeTranslations);
 }
Ejemplo n.º 35
0
			/// ------------------------------------------------------------------------------------
			/// <summary>
			/// Initializes a new instance of the FootnoteVc class
			/// </summary>
			/// ------------------------------------------------------------------------------------
			public DummyFootnoteVc(FdoCache cache) : base(cache.WritingSystemFactory.UserWs)
			{
				m_stvc = new StVc(cache.WritingSystemFactory.UserWs);
				m_stvc.Cache = cache;
			}
		public override void TestSetup()
		{
			base.TestSetup();

			m_vc = new StVc();
			m_vc.Cache = Cache;

			m_pattern = VwPatternClass.Create();
			m_strFactory = TsStrFactoryClass.Create();

			m_pattern.Pattern = m_strFactory.MakeString("a", Cache.DefaultVernWs);
			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;

			IScrBook genesis = AddBookWithTwoSections(1, "Genesis");
			m_section = genesis.SectionsOS[0];
			// Add paragraphs (because we use an StVc in the test we add them all to the same section)
			m_para1 = AddParaToMockedSectionContent(m_section,
				ScrStyleNames.NormalParagraph);
			AddRunToMockedPara(m_para1,
				"This is some text so that we can test the find functionality.", null);
			m_para2 = AddParaToMockedSectionContent(m_section,
				ScrStyleNames.NormalParagraph);
			AddRunToMockedPara(m_para2,
				"Some more text so that we can test the find and replace functionality.", null);
			m_para3 = AddParaToMockedSectionContent(
				m_section, ScrStyleNames.NormalParagraph);
			AddRunToMockedPara(m_para3,
				"This purugruph doesn't contuin the first letter of the ulphubet.", null);
		}
Ejemplo n.º 37
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Insert the body of a paragraph. This is normally (with fApplyProps true) the body
        /// of case kfrPara and kfrFootnotePara in the Display method, but some subclasses
        /// need to separate this from applying the properties.
        /// </summary>
        /// <param name="vwenv"></param>
        /// <param name="paraHvo"></param>
        /// <param name="frag"></param>
        /// <param name="fApplyProps"></param>
        /// <param name="contentType"></param>
        /// <param name="vc">The view constructor used to create the paragraphs</param>
        /// ------------------------------------------------------------------------------------
        protected void InsertParagraphBody(IVwEnv vwenv, int paraHvo, int frag, bool fApplyProps,
                                           ContentTypes contentType, StVc vc)
        {
            vc.SetupWsAndDirectionForPara(vwenv, paraHvo);

            if (fApplyProps)
            {
                ApplyParagraphStyleProps(vwenv, paraHvo, vc);
            }

            // This was causing assertions in the layoutmgr
            // TODO (TE-5777): Should be able to do this with an in-memory stylesheet.
            //			if (DisplayTranslation)
            //			{
            //				// display the back translation text as double spaced
            //				vwenv.set_IntProperty((int)FwTextPropType.ktptLineHeight,
            //					(int)FwTextPropVar.ktpvRelative, 20000);
            //			}
            // The body of the paragraph is either editable or not.
            vwenv.set_IntProperty((int)FwTextPropType.ktptEditable, (int)FwTextPropVar.ktpvEnum,
                                  vc.Editable ? (int)TptEditable.ktptIsEditable : (int)TptEditable.ktptNotEditable);
            // Make the paragraph containing the paragraph contents.
            OpenPara(vwenv, paraHvo);
            // Cause a regenerate when the style changes...this is mainly used for Undo.
            vwenv.NoteDependency(new[] { paraHvo }, new[] { StParaTags.kflidStyleRules }, 1);
            // Insert the label if it is the first paragraph.
            if (vc.Label != null)
            {
                int lev = vwenv.EmbeddingLevel;
                int hvoOuter;
                int ihvoItem;
                int tagOuter;
                vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
                if (ihvoItem == 0)
                {
                    vwenv.AddObj(paraHvo, vc, (int)StTextFrags.kfrLabel);
                }
            }
            if (frag == (int)StTextFrags.kfrFootnotePara)
            {
                int lev = vwenv.EmbeddingLevel;
                int hvoOuter;
                int ihvoItem;
                int tagOuter;
                vwenv.GetOuterObject(lev - 1, out hvoOuter, out tagOuter, out ihvoItem);
                // Note a dependency on the footnote options so that the footnote will
                // be refreshed when these are changed.
                // If this is the 1st paragraph in the footnote...
                if (ihvoItem == 0)
                {
                    vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteMarker);
                    vwenv.AddObj(hvoOuter, vc, (int)StTextFrags.kfrFootnoteReference);
                }
            }

            if (contentType == ContentTypes.kctSimpleBT)
            {
                // If a translation is being shown instead of the paragraph, then show it instead
                // of the text of the paragraph.
                vwenv.AddObj(GetTranslationForPara(paraHvo), vc, (int)StTextFrags.kfrTranslation);
                if (!PrintLayout)
                {
                    // This dependency is here so that the "Missing" prompt will be added to the
                    // view when the first character is typed in the contents. But to solve the
                    // problem with losing the IP when typing (FWR-1415), the dependency is not
                    // added in print layout views. The missing prompt seems less of a problem
                    // than the problem with typing.
                    vwenv.NoteDependency(new[] { paraHvo }, new[] { StTxtParaTags.kflidContents }, 1);
                }
            }
            else if (contentType == ContentTypes.kctSegmentBT)
            {
                vwenv.AddObjVecItems(StTxtParaTags.kflidSegments, vc, (int)StTextFrags.kfrSegmentFreeTranslations);
            }
            else if (!InsertParaContentsUserPrompt(vwenv, paraHvo))
            {
                // Display the text paragraph contents, or its user prompt.
                vwenv.AddStringProp(StTxtParaTags.kflidContents, null);
            }

            // Display an "end-of-paragraph" marker if needed
            InsertEndOfParaMarks(vwenv, paraHvo);

            vwenv.CloseParagraph();
        }
Ejemplo n.º 38
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Invoke the paragraph's style rule if any. The properties will apply to the next
		/// flow object--typically a paragraph, but in one TE case a picture--opened or added
		/// next.
		/// </summary>
		/// <param name="vwenv"></param>
		/// <param name="paraHvo">The HVO of the paragraph</param>
		/// <param name="vc">The view constructor</param>
		/// ------------------------------------------------------------------------------------
		protected static void ApplyParagraphStyleProps(IVwEnv vwenv, int paraHvo, StVc vc)
		{
			// Decide what style to apply to the paragraph.
			// Rules:
			//	1. Apply the paragraph's own style, or "Normal" if it has none.
			//	2. If the creator of the view constructor specified a default style
			//		and background color, invoke those as overrides.
			ITsTextProps tsTextProps = (ITsTextProps)vwenv.DataAccess.get_UnknownProp(paraHvo,
				StParaTags.kflidStyleRules);

			if (vc.DefaultParaStyle.Length > 0)
			{
				vwenv.set_StringProperty((int)FwTextPropType.ktptNamedStyle,
					vc.DefaultParaStyle);
				vwenv.set_IntProperty((int)FwTextPropType.ktptParaColor,
					(int)FwTextPropVar.ktpvDefault, vc.BackColor.ToArgb());
			}
			// The style the user has explicitly set on the paragraph should override the VC's default style.
			vwenv.Props = tsTextProps ?? vc.NormalStyle;
		}