Exemplo n.º 1
0
		/// <summary>
		///  Create one from the specified end of the selection. If that end is not in a
		/// relevant property return null. Also return null if in the same StText as
		/// hvoOther.
		/// </summary>
		/// <param name="info"></param>
		/// <param name="fEndPoint"></param>
		static public TextStateInfo Create(TextSelInfo info, bool fEndPoint, FdoCache cache, int hvoOther)
		{
			int offset = 0; // in the SelInfoStack
			if (info.Tag(fEndPoint) == kflidContents)
			{
				if (info.Levels(fEndPoint) < 2)
					return null;
			}
			else
			{
				// One other case we need to handle is an embedded picture, because deleting it will modify the string.
				if (!info.IsPicture || info.Levels(false) < 3 || info.ContainingObjectTag(1) != kflidContents)
					return null;
				offset = 1; // one more level for the picture.
			}
			int hvoStText = info.ContainingObject(1 + offset, fEndPoint);
			if (hvoStText == hvoOther)
				return null;
			TextStateInfo result = new TextStateInfo();
			result.m_stText = CmObject.CreateFromDBObject(cache, hvoStText) as StText;;
			result.m_hvoPara = info.ContainingObject(offset, fEndPoint);
			foreach (StTxtPara para in result.m_stText.ParagraphsOS)
				result.m_paras.Add(new ParaStateInfo(para));
			result.m_tssAnchorText = cache.GetTsStringProperty(result.m_hvoPara, kflidContents);
			result.m_fCheckOtherParasOfText = true;
			return result;
		}
Exemplo n.º 2
0
		internal static string[] AddStringFromOtherObj(XmlNode frag, int hvoTarget, FdoCache cache)
		{
			int flid = XmlVc.GetFlid(frag, hvoTarget, cache);
			ITsStrFactory tsf = TsStrFactoryClass.Create();
			FieldType itype = cache.GetFieldType(flid);
			if ((itype == FieldType.kcptUnicode) ||
				(itype == FieldType.kcptBigUnicode))
			{
				return new string[] {cache.GetUnicodeProperty(hvoTarget, flid)};
			}
			else if ((itype == FieldType.kcptString) ||
				(itype == FieldType.kcptBigString))
			{
				return new string[] { cache.GetTsStringProperty(hvoTarget, flid).Text };
			}
			else // multistring of some type
			{
				int wsid = 0;
				string sep = "";
				if (s_cwsMulti > 1)
				{
					string sLabelWs = XmlUtils.GetOptionalAttributeValue(frag, "ws");
					if (sLabelWs != null && sLabelWs == "current")
					{
						sep = DisplayMultiSep(frag, cache)
							+ DisplayWsLabel(s_qwsCurrent, cache);
						wsid = s_qwsCurrent.WritingSystem;
					}
				}
				if (wsid == 0)
					wsid = LangProject.GetWritingSystem(frag, cache, null, LangProject.kwsAnal);
				if ((itype == FieldType.kcptMultiUnicode) ||
					(itype == FieldType.kcptMultiBigUnicode))
				{
					return new string[] {sep, cache.GetMultiUnicodeAlt(hvoTarget, flid, wsid, null) };
				}
				else
				{
					return new string[] {sep, cache.GetMultiStringAlt(hvoTarget, flid, wsid).Text };
				}
			}
		}
Exemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the ws at para offset.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="hvoPara">The hvo para.</param>
		/// <param name="ichBeginOffset">The ich begin offset.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public static int GetWsAtParaOffset(FdoCache cache, int hvoPara, int ichBeginOffset)
		{
			//Debug.Assert(cache.IsValidObject(hvoPara, StTxtPara.kClassId),
			//    String.Format("expected valid hvo({0}).", hvoPara));
			//if (hvoPara <= 0 && !cache.IsDummyObject(hvoPara))
			//    throw new ArgumentException(String.Format("expected valid hvo({0}).", hvoPara));
			ITsString tssPara = cache.GetTsStringProperty(hvoPara, (int)StTxtPara.StTxtParaTags.kflidContents);
			int ws = StringUtils.GetWsAtOffset(tssPara, ichBeginOffset);
			return ws;
		}
Exemplo n.º 4
0
		internal static ITsString AnnotationTargetString(int hvoTarget, int flid, int ws, FdoCache cache)
		{
			ITsString tssValue;
			if (IsMultilingual(flid))
			{
				tssValue = cache.GetMultiStringAlt(hvoTarget, flid, ws);
			}
			else
			{
				tssValue = cache.GetTsStringProperty(hvoTarget, flid);
			}
			return tssValue;
		}