예제 #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Look for a previous translation with a matching status in a paragraph of an StText
		/// </summary>
		/// <param name="text">StText to search through</param>
		/// <param name="searchStatus">status of the CmTranslation that we want to find</param>
		/// <param name="iParaStartSearch">Index of the paragraph where search starts</param>
		/// <returns>an index of the found paragraph in the StText or -1 if not found</returns>
		/// ------------------------------------------------------------------------------------
		private int FindPrevTranslationInText(IStText text, BackTranslationStatus searchStatus,
			int iParaStartSearch)
		{
			// Look through all of the paragraphs in the StText.
			for (int paraIndex = iParaStartSearch; paraIndex >= 0; paraIndex--)
			{
				IStTxtPara para = (IStTxtPara)text.ParagraphsOS[paraIndex];

				// Get the translation for this paragraph. If it has the desired state then
				// return it.
				ICmTranslation trans = para.GetOrCreateBT();
				if (GetBackTranslationStatus(trans) == searchStatus)
					return paraIndex;
			}

			// It was not found in this StText
			return -1;
		}
예제 #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the status of a back translation object.
		/// </summary>
		/// <param name="trans"></param>
		/// <param name="status"></param>
		/// ------------------------------------------------------------------------------------
		protected void SetBackTranslationStatus(ICmTranslation trans, BackTranslationStatus status)
		{
			Debug.Assert(trans.TypeRA.Guid == LangProjectTags.kguidTranBackTranslation);
			trans.Status.set_String(ViewConstructorWS, status.ToString());
			// We shouldn't have to do this in the new FDO
			//m_fdoCache.MainCacheAccessor.PropChanged(null,
			//    (int)PropChangeType.kpctNotifyAll, trans.Hvo,
			//    CmTranslationTags.kflidStatus, 0, 1, 1);
		}
예제 #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Find and select the previous translation with a given state
		/// </summary>
		/// <param name="selection">The selection where to start the search.
		/// NOTE: The selection must have all of the info set in the LevelInfo (hvo, ihvo)</param>
		/// <param name="searchStatus">Back translation status to search for</param>
		/// ------------------------------------------------------------------------------------
		private void MoveToPrevTranslation(SelectionHelper selection,
			BackTranslationStatus searchStatus)
		{
			SelLevInfo bookInfo;
			SelLevInfo paraInfo;
			SelLevInfo sectionInfo;
			bool fFoundBookLevel = selection.GetLevelInfoForTag(BookFilter.Tag, out bookInfo);
			bool fFoundSectionLevel = selection.GetLevelInfoForTag(
				ScrBookTags.kflidSections, out sectionInfo);
			int secLev = selection.GetLevelForTag(ScrBookTags.kflidSections);
			bool fFoundParaLevel = selection.GetLevelInfoForTag(
				StTextTags.kflidParagraphs, out paraInfo);

			if (!fFoundBookLevel || !fFoundParaLevel)
				return;

			// Look through all the books in the book filter
			int bookStartIndex = bookInfo.ihvo;
			int sectionStartIndex = -1;
			int sectionTag = ScrSectionTags.kflidContent;
			int paraStartIndex = paraInfo.ihvo - 1;
			int paraIndex;

			if (fFoundSectionLevel)
			{
				// start with current section
				sectionStartIndex = sectionInfo.ihvo;
				sectionTag = selection.LevelInfo[secLev - 1].tag;
			}
			else
			{
				// no section, so this must be the title - Look through the title paragraphs
				IScrBook checkBook = BookFilter.GetBook(bookStartIndex);
				paraIndex = FindPrevTranslationInText(checkBook.TitleOA, searchStatus,
					paraStartIndex);
				if (paraIndex >= 0)
				{
					// select the title paragraph
					SetInsertionPoint(ScrBookTags.kflidTitle, bookStartIndex, 0, paraIndex);
					return;
				}
				// continue the search with the previous book
				bookStartIndex--;
				paraStartIndex = -2;
			}

			for (int bookIndex = bookStartIndex; bookIndex >= 0 ; bookIndex--)
			{
				IScrBook checkBook = BookFilter.GetBook(bookIndex);
				if (sectionStartIndex == -1)
				{
					sectionStartIndex = checkBook.SectionsOS.Count - 1;
					sectionTag = ScrSectionTags.kflidContent;
				}

				// Look through the sections in reverse order.
				for (int sectionIndex = sectionStartIndex; sectionIndex >= 0; sectionIndex--)
				{
					IScrSection checkSection = checkBook.SectionsOS[sectionIndex];

					if (paraStartIndex == -2)
					{
						paraStartIndex = checkSection.ContentOA.ParagraphsOS.Count - 1;
						sectionTag = ScrSectionTags.kflidContent;
					}

					// Look in the paragraphs (could be either content or heading)
					IStText text = (sectionTag == ScrSectionTags.kflidHeading) ?
						checkSection.HeadingOA : checkSection.ContentOA;
					paraIndex = FindPrevTranslationInText(text, searchStatus, paraStartIndex);
					if (paraIndex >= 0)
					{
						// select the paragraph
						SetInsertionPoint(sectionTag, bookIndex, sectionIndex, paraIndex);
						return;
					}

					// Look in the heading paragraphs, if we haven't already
					if (sectionTag == ScrSectionTags.kflidContent)
					{
						sectionTag = ScrSectionTags.kflidHeading;
						int startHeadPara = checkSection.HeadingOA.ParagraphsOS.Count - 1;
						paraIndex = FindPrevTranslationInText(checkSection.HeadingOA, searchStatus,
							startHeadPara);
						if (paraIndex >= 0)
						{
							// select the heading paragraph
							SetInsertionPoint(sectionTag, bookIndex, sectionIndex, paraIndex);
							return;
						}
					}
					paraStartIndex = -2;
				}
				sectionStartIndex = -1;

				// Look through the title paragraphs
				int startTitlePara = checkBook.TitleOA.ParagraphsOS.Count - 1;
				paraIndex = FindPrevTranslationInText(checkBook.TitleOA, searchStatus, startTitlePara);
				if (paraIndex >= 0)
				{
					// select the title paragraph
					SetInsertionPoint(ScrBookTags.kflidTitle, bookIndex, 0, paraIndex);
					return;
				}
			}
		}
예제 #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets the back translation status.
		/// </summary>
		/// <param name="trans">The translation.</param>
		/// <param name="status">The status.</param>
		/// ------------------------------------------------------------------------------------
		public void SetTransStatus(ICmTranslation trans, BackTranslationStatus status)
		{
			CheckDisposed();

			SetBackTranslationStatus(trans, status);
		}
예제 #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the back translation status.
        /// </summary>
        /// <param name="trans">The translation.</param>
        /// <param name="status">The status.</param>
        /// ------------------------------------------------------------------------------------
        public void SetTransStatus(ICmTranslation trans, BackTranslationStatus status)
        {
            CheckDisposed();

            SetBackTranslationStatus(trans, status);
        }
예제 #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Find and select the next translation with a given state
		/// </summary>
		/// <param name="selection">The selection where to start the search.
		/// NOTE: The selection must have all of the info set in the LevelInfo (hvo, ihvo)</param>
		/// <param name="searchStatus">Back translation status to search for</param>
		/// ------------------------------------------------------------------------------------
		private void MoveToNextTranslation(SelectionHelper selection,
			BackTranslationStatus searchStatus)
		{
			SelLevInfo bookInfo;
			SelLevInfo paraInfo;
			SelLevInfo sectionInfo;
			bool fFoundBookLevel = selection.GetLevelInfoForTag(BookFilter.Tag, out bookInfo);
			bool fFoundSectionLevel = selection.GetLevelInfoForTag(
				(int)ScrBook.ScrBookTags.kflidSections, out sectionInfo);
			int secLev = selection.GetLevelForTag((int)ScrBook.ScrBookTags.kflidSections);
			bool fFoundParaLevel = selection.GetLevelInfoForTag(
				(int)StText.StTextTags.kflidParagraphs, out paraInfo);

			if (!fFoundBookLevel || !fFoundParaLevel)
				return;

			// Look through all the books in the book filter
			int bookStartIndex = bookInfo.ihvo;
			int sectionStartIndex = 0;
			int sectionTag = (int)ScrSection.ScrSectionTags.kflidContent;
			int paraStartIndex = paraInfo.ihvo + 1;
			int paraIndex;

			if (fFoundSectionLevel)
			{
				// start with current section
				sectionStartIndex = sectionInfo.ihvo;
				sectionTag = selection.LevelInfo[secLev - 1].tag;
			}
			else
			{
				// no section, so this must be the title - Look through the title paragraphs
				ScrBook checkBook = BookFilter.GetBook(bookStartIndex);
				paraIndex = FindNextTranslationInText(checkBook.TitleOA, searchStatus,
					paraStartIndex);
				if (paraIndex >= 0)
				{
					// select the title paragraph
					SetInsertionPoint((int)ScrBook.ScrBookTags.kflidTitle, bookStartIndex,
						0, paraIndex);
					return;
				}
				// continue the search with the current book
				sectionTag = (int)ScrSection.ScrSectionTags.kflidHeading;
				paraStartIndex = 0;
			}

			for (int bookIndex = bookStartIndex; bookIndex < BookFilter.BookCount; bookIndex++)
			{
				ScrBook checkBook = BookFilter.GetBook(bookIndex);
				if (bookIndex > bookStartIndex)
				{
					// Look through the title paragraphs
					paraIndex = FindNextTranslationInText(checkBook.TitleOA, searchStatus, 0);
					if (paraIndex >= 0)
					{
						// select the title paragraph
						SetInsertionPoint((int)ScrBook.ScrBookTags.kflidTitle, bookIndex, 0, paraIndex);
						return;
					}
				}

				// Look through the sections in order.
				for (int sectionIndex = sectionStartIndex;
					sectionIndex < checkBook.SectionsOS.Count; sectionIndex++)
				{
					IScrSection checkSection = checkBook.SectionsOS[sectionIndex];

					// Look in the paragraphs (could be either content or heading)
					IStText text = (sectionTag == (int)ScrSection.ScrSectionTags.kflidHeading) ?
						checkSection.HeadingOA : checkSection.ContentOA;
					paraIndex = FindNextTranslationInText(text, searchStatus, paraStartIndex);
					if (paraIndex >= 0)
					{
						// select the paragraph
						SetInsertionPoint(sectionTag, bookIndex, sectionIndex, paraIndex);
						return;
					}

					// Look in the heading paragraphs, if we haven't already
					if (sectionTag == (int)ScrSection.ScrSectionTags.kflidHeading)
					{
						sectionTag = (int)ScrSection.ScrSectionTags.kflidContent;
						paraIndex = FindNextTranslationInText(checkSection.ContentOA,
							searchStatus, 0);
						if (paraIndex >= 0)
						{
							// select the heading paragraph
							SetInsertionPoint(sectionTag, bookIndex, sectionIndex, paraIndex);
							return;
						}
					}

					sectionTag = (int)ScrSection.ScrSectionTags.kflidHeading;
					paraStartIndex = 0;
				}
				sectionStartIndex = 0;
			}
		}
예제 #7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the status of a back translation object.
		/// </summary>
		/// <param name="trans"></param>
		/// <param name="status"></param>
		/// ------------------------------------------------------------------------------------
		protected void SetBackTranslationStatus(ICmTranslation trans, BackTranslationStatus status)
		{
			Debug.Assert(trans.TypeRA.Guid == LangProject.kguidTranBackTranslation);
			string undo;
			string redo;
			TeResourceHelper.MakeUndoRedoLabels("kstidUndoRedoChangeBackTransStatus", out undo, out redo);
			using (UndoTaskHelper undoTaskHelper = new UndoTaskHelper(this,
					  undo, redo, false))
			{
				trans.Status.SetAlternative(status.ToString(), ViewConstructorWS);
				m_fdoCache.MainCacheAccessor.PropChanged(null,
					(int)PropChangeType.kpctNotifyAll, trans.Hvo,
					(int)CmTranslation.CmTranslationTags.kflidStatus, 0, 1, 1);
			}
		}