SetTextPropId() public method

Sets the text property that occurs at the indicated end of the selection.
public SetTextPropId ( SelLimitType type, int tagTextProp ) : void
type SelLimitType Anchor or End
tagTextProp int Text property
return void
Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Makes the selection in in the Scripture reference of the specified annotation.
		/// </summary>
		/// <param name="vc">The vc.</param>
		/// <param name="bookIndex">Index of the book.</param>
		/// <param name="iAnnotation">Index of the annotation.</param>
		/// <param name="notesDataEntryView">The notes data entry view.</param>
		/// ------------------------------------------------------------------------------------
		internal void MakeSelectionInNoteRef(TeNotesVc vc, int bookIndex, int iAnnotation,
			NotesDataEntryView notesDataEntryView)
		{
			EnsureNoteIsVisible(vc, bookIndex, iAnnotation, notesDataEntryView);

			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = 2;
			selHelper.LevelInfo[0].cpropPrevious = 0;
			selHelper.LevelInfo[0].ich = -1;
			selHelper.LevelInfo[0].ihvo = iAnnotation;
			selHelper.LevelInfo[0].tag = vc.NotesSequenceHandler.Tag;
			selHelper.LevelInfo[0].ws = 0;
			selHelper.LevelInfo[1].cpropPrevious = 0;
			selHelper.LevelInfo[1].ich = -1;
			selHelper.LevelInfo[1].ihvo = bookIndex;
			selHelper.LevelInfo[1].tag = (int)Scripture.ScriptureTags.kflidBookAnnotations;
			selHelper.LevelInfo[1].ws = 0;
			selHelper.IchAnchor = 0;
			selHelper.AssocPrev = false;
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
				(int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginRef);

			selHelper.SetSelection(notesDataEntryView, true, true, VwScrollSelOpts.kssoDefault);
		}
Ejemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Low-level implementation of insert verse number.
		/// </summary>
		/// <param name="selHelper">the given SelectionHelper</param>
		/// ------------------------------------------------------------------------------------
		public void InsertVerseNumber(SelectionHelper selHelper)
		{
			CheckDisposed();
			Debug.Assert(selHelper != null);
			Debug.Assert(!selHelper.IsRange);

			// Get the details about the current selection
			int ichSelOrig; //the character offset of the selection in the ITsString
			int hvoObj; //the id of the object the selection is in (StTxtPara or CmTranslation)
			int propTag; //property tag of object
			ITsString tssSel; //ITsString containing the selection
			int wsAlt; //the WS of the multiString alt, if selection is in a back translation
			ichSelOrig = GetSelectionInfo(selHelper, out hvoObj, out propTag, out tssSel, out wsAlt);

			// If we're at the start of a paragraph and the first run is a chapter number,
			// we need to jump past it to insert the verse number otherwise it will insert
			// it before the chapter number, which for some reason feels brain dead.
			if (ichSelOrig == 0)
			{
				ITsTextProps ttp = tssSel.get_Properties(0);
				if (ttp.GetStrPropValue((int)FwTextPropType.ktptNamedStyle) ==
					ScrStyleNames.ChapterNumber)
				{
					ichSelOrig = tssSel.get_LimOfRun(0);
				}
			}

			// Adjust the insertion position to the beginning of a word - not in the middle
			//  (may move to an existing verse number too)
			int ichWord = MoveToWordBoundary(tssSel, ichSelOrig);

			//			TomB and MarkB have decided we won't do this, at least for now
			//			// If the start of the Bt does not match the vernacular, adjust it if required.
			//			if (ichWord > 0)
			//				cInsDel = SetVerseAtStartOfBtIfNeeded();
			//			ichWord += cInsDel; //adjust

			// some key variables set by Update or Insert methods, etc
			string sVerseNumIns = null; // will hold the verse number string we inserted; could be
			//   a simple number, a verse bridge, or the end number added to a bridge
			string sChapterNumIns = null; // will hold chapter number string inserted or null if none
			int ichLimIns = -1; //will hold the end of the new chapter/verse numbers we update or insert

			// Is ichWord in or next to a verse number? (if so, get its ich range)
			bool fCheckForChapter = (wsAlt != 0); //check for chapter in BT only
			int ichMin; // min of the verse number run, if we are on one
			int ichLim; // lim of the verse number run, if we are on one
			bool fFoundExistingRef =
				InReference(tssSel, ichWord, fCheckForChapter, out ichMin, out ichLim);

			// If we moved the selection forward (over spaces or punctuation) to an
			//  existing verse number ...
			if (fFoundExistingRef && (ichSelOrig < ichWord))
			{
				//Attempt to insert a verse number at the IP, if one is missing there.
				// if selection is in vernacular...
				if (propTag == (int)StTxtPara.StTxtParaTags.kflidContents)
				{
					// Insert missing verse number in vernacular
					InsertMissingVerseNumberInVern(hvoObj, propTag, selHelper, ichSelOrig,
						ichWord, ref tssSel, out sVerseNumIns, out ichLimIns);
				}
				//else
				//{
				//    InsertMissingVerseNumberInBt(hvoObj, propTag, selHelper, wsAlt,
				//        ichSelOrig, ichWord, ref tssSel, ref ichLim,
				//        out sVerseNumIns, out sChapterNumIns);
				//}
				// if a verse number was not inserted, sVerseNumIns is null
			}

			// If no verse number inserted yet...
			if (sVerseNumIns == null)
			{
				if (fFoundExistingRef)
				{
					//We must update the existing verse number at ichWord
					// is selection in vern or BT?
					if (propTag == (int)StTxtPara.StTxtParaTags.kflidContents)
					{
						// Update verse number in vernacular
						UpdateExistingVerseNumberInVern(hvoObj, propTag, selHelper,
							ichMin, ichLim, ref tssSel, out sVerseNumIns, out ichLimIns);
					}
					else
					{
						//Update verse number in back translation
						UpdateExistingVerseNumberInBt(hvoObj, propTag, selHelper, wsAlt,
							ichMin, ichLim, ref tssSel, out sVerseNumIns, out sChapterNumIns,
							out ichLimIns);
					}
				}
				else
				{
					// We're NOT on an existing verse number, so insert the next appropriate one.
					// is selection in vern or BT?
					if (propTag == (int)StTxtPara.StTxtParaTags.kflidContents)
					{
						InsertNextVerseNumberInVern(hvoObj, propTag, selHelper, ichWord,
							ref tssSel, out sVerseNumIns, out ichLimIns);
					}
					else
					{
						InsertNextVerseNumberInBt(hvoObj, propTag, selHelper, wsAlt, ichWord,
							ref tssSel, out	sVerseNumIns, out sChapterNumIns, out ichLimIns);
						selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
							(int)CmTranslation.CmTranslationTags.kflidTranslation);
						selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
							(int)CmTranslation.CmTranslationTags.kflidTranslation);
					}
				}
			}

			if (sVerseNumIns == null)
			{
				MiscUtils.ErrorBeep(); // No verse number inserted or updated
				return;
			}

			// set new IP behind the verse number
			selHelper.IchAnchor = ichLimIns;
			selHelper.IchEnd = ichLimIns;
			selHelper.AssocPrev = true;
			selHelper.SetSelection(true);

			// Remove any duplicate chapter/verse numbers following the new verse number.
			RemoveDuplicateVerseNumbers(hvoObj, propTag, tssSel, wsAlt, sChapterNumIns,
				sVerseNumIns, ichLimIns);

			// Issue property change event for inserted verse.
			m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoObj,
				StTxtPara.ktagVerseNumbers, 0, 1, 1);
		}
Ejemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Makes a selection in the specified annotation (without scrolling the annotation in
		/// the view).
		/// </summary>
		/// <param name="vc">The notes view constructor</param>
		/// <param name="fScrollNearTop">if set to <c>true</c> scrolls the specified note to a
		/// position near the top of the view.</param>
		/// <param name="bookIndex">Index of the book.</param>
		/// <param name="iAnnotation">Index of the annotation.</param>
		/// <param name="iResponse">Index of the response (0 if setting the selection in one of
		/// the StJournalText fields rather than in a response.</param>
		/// <param name="noteTag">The tag indicating the field of the annotation where the
		/// selection is to be made.</param>
		/// <param name="rootSite">The root site.</param>
		/// <param name="fNoteIsExpanded">if <c>true</c> make a selection at the start and end so
		/// that the whole annotation can be scrolled into view. if set to <c>false</c> only
		/// make a selection at the start of the annotation.</param>
		/// ------------------------------------------------------------------------------------
		internal void MakeSelectionInNote(TeNotesVc vc, bool fScrollNearTop, int bookIndex,
			int iAnnotation, int iResponse, ScrScriptureNote.ScrScriptureNoteTags noteTag,
			IVwRootSite rootSite, bool fNoteIsExpanded)
		{
			if (vc == null || vc.NotesSequenceHandler == null)
				return;

			SelectionHelper selHelper;
			if (fScrollNearTop)
			{
				// Make an un-installed selection at the top of the annotation in order to scroll the
				// annotation to the top of the view.
				selHelper = new SelectionHelper();
				selHelper.NumberOfLevels = 2;
				selHelper.LevelInfo[0].cpropPrevious = 0;
				selHelper.LevelInfo[0].ich = -1;
				selHelper.LevelInfo[0].ihvo = iAnnotation;
				selHelper.LevelInfo[0].tag = vc.NotesSequenceHandler.Tag;
				selHelper.LevelInfo[0].ws = 0;
				selHelper.LevelInfo[1].cpropPrevious = 0;
				selHelper.LevelInfo[1].ich = -1;
				selHelper.LevelInfo[1].ihvo = bookIndex;
				selHelper.LevelInfo[1].tag = (int)Scripture.ScriptureTags.kflidBookAnnotations;
				selHelper.LevelInfo[1].ws = 0;
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, -2);
				selHelper.IchAnchor = 0;
				selHelper.AssocPrev = false;
				selHelper.NumberOfPreviousProps = 2;
				if (fNoteIsExpanded)
				{
					selHelper.SetSelection(rootSite, true, true, VwScrollSelOpts.kssoNearTop);
				}
				else
				{
					// Annotation is collapsed. Only attempt a selection at the start of it.
					selHelper.SetSelection(rootSite, true, true);
					return;
				}
			}
			else
				EnsureNoteIsVisible(vc, bookIndex, iAnnotation, rootSite);

			// Now make the real (installed) selection in the desired field of the annotation.
			bool fIsResponse = (noteTag == ScrScriptureNote.ScrScriptureNoteTags.kflidResponses);
			selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = 4;
			selHelper.LevelInfo[0].tag = (int)StText.StTextTags.kflidParagraphs;
			selHelper.LevelInfo[0].ihvo = 0;
			selHelper.LevelInfo[1].tag = (int)noteTag;
			selHelper.LevelInfo[1].ihvo = iResponse;
			selHelper.LevelInfo[1].cpropPrevious = (fIsResponse ? 0 : 1);
			selHelper.LevelInfo[2].tag = vc.NotesSequenceHandler.Tag;
			selHelper.LevelInfo[2].ihvo = iAnnotation;
			selHelper.LevelInfo[3].tag = (int)Scripture.ScriptureTags.kflidBookAnnotations;
			selHelper.LevelInfo[3].ihvo = bookIndex;
			selHelper.IchAnchor = 0;
			selHelper.AssocPrev = false;
			selHelper.SetSelection(rootSite, true, true);
		}
Ejemplo n.º 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This is the actual workhorse for all the above methods that allows a selection to
		/// be created.
		/// </summary>
		/// <param name="iBook">The 0-based index of the Scripture book in which to put the
		/// selection</param>
		/// <param name="iSection">The 0-based index of the Scripture section in which to put the
		/// selection</param>
		/// <param name="tag">Indicates whether selection should be made in the section
		/// Heading or Content or in the book title</param>
		/// <param name="isegment">If ContentType == segmentBT, the index of the segment
		/// in which to place the selection; otherwise ignored.</param>
		/// <param name="iPara">The 0-based index of the paragraph in which to put the insertion
		/// point</param>
		/// <param name="startCharacter">The 0-based index of the character at which the
		/// selection begins (or before which the insertion point is to be placed if
		/// startCharacter == endCharacter)</param>
		/// <param name="endCharacter">The character location to end the selection</param>
		/// <param name="fInstall"></param>
		/// <param name="fMakeVisible"></param>
		/// <param name="fAssocPrev">If an insertion point, does it have the properties of the
		/// previous character?</param>
		/// <param name="scrollOption">Where to scroll the selection</param>
		/// <returns>The selection helper</returns>
		/// ------------------------------------------------------------------------------------
		public SelectionHelper SelectRangeOfChars(int iBook, int iSection, int tag,
			int iPara, int isegment, int startCharacter, int endCharacter, bool fInstall, bool fMakeVisible,
			bool fAssocPrev, VwScrollSelOpts scrollOption)
		{
			CheckDisposed();

			if (Callbacks == null || Callbacks.EditedRootBox == null)
				return null;  // can't make a selection

			Debug.Assert(tag == (int)ScrSection.ScrSectionTags.kflidHeading ||
				tag == (int)ScrSection.ScrSectionTags.kflidContent ||
				tag == (int)ScrBook.ScrBookTags.kflidTitle);

			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = ((ITeView)Control).LocationTracker.GetLevelCount(tag);
			int levelForPara = LocationTrackerImpl.GetLevelIndexForTag((int)StText.StTextTags.kflidParagraphs,
				m_contentType);

			selHelper.LevelInfo[levelForPara].ihvo = iPara;
			selHelper.LevelInfo[levelForPara + 1].tag = tag;

			((ITeView)Control).LocationTracker.SetBookAndSection(selHelper,
				SelectionHelper.SelLimitType.Anchor, iBook,
				tag == (int)ScrBook.ScrBookTags.kflidTitle ? -1 : iSection);

			if (ContentType == StVc.ContentTypes.kctSimpleBT)
			{
				int levelForBT = LocationTrackerImpl.GetLevelIndexForTag((int)StTxtPara.StTxtParaTags.kflidTranslations,
					m_contentType);
				selHelper.LevelInfo[levelForBT].tag = -1;
				selHelper.LevelInfo[levelForBT].ihvo = 0;
				selHelper.LevelInfo[levelForPara].tag = (int)StText.StTextTags.kflidParagraphs;
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
					(int)CmTranslation.CmTranslationTags.kflidTranslation);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
					(int)CmTranslation.CmTranslationTags.kflidTranslation);
			}
			else if (ContentType == StVc.ContentTypes.kctSegmentBT)
			{
				// In all segment BT views, under the paragraph there is a segment, and under that
				// an object which is the free translation itself.
				selHelper.LevelInfo[2].tag = (int) StText.StTextTags.kflidParagraphs; // JohnT: why don't we need this for non-BT??
				selHelper.LevelInfo[1].ihvo = isegment;
				selHelper.LevelInfo[1].tag = StTxtPara.SegmentsFlid(Cache);
				selHelper.LevelInfo[0].ihvo = 0; // not a sequence.
				selHelper.LevelInfo[0].tag = StTxtPara.SegmentFreeTranslationFlid(Cache);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
					(int)CmAnnotation.CmAnnotationTags.kflidComment);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
					(int)CmAnnotation.CmAnnotationTags.kflidComment);
			}
			// else	selHelper.LevelInfo[0].tag is set automatically by SelectionHelper class

			selHelper.AssocPrev = fAssocPrev;
			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selHelper.LevelInfo);

			// Prepare to move the IP to the specified character in the paragraph.
			selHelper.IchAnchor = startCharacter;
			selHelper.IchEnd = endCharacter;

			// Now that all the preparation to set the IP is done, set it.
			IVwSelection vwsel = selHelper.SetSelection(Callbacks.EditedRootBox.Site, fInstall,
				fMakeVisible, scrollOption);

			// If the selection fails, then try selecting the user prompt.
			if (vwsel == null)
			{
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, SimpleRootSite.kTagUserPrompt);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, SimpleRootSite.kTagUserPrompt);
				vwsel = selHelper.SetSelection(Callbacks.EditedRootBox.Site, fInstall, fMakeVisible,
					scrollOption);
			}

			if (vwsel == null)
			{
				Debug.WriteLine("SetSelection failed in TeEditinHelper.SelectRangeOfChars()");
			}

			return selHelper;
		}
Ejemplo n.º 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Makes a selection in a picture caption.
		/// </summary>
		/// <param name="iBook">The 0-based index of the Scripture book in which to put the
		/// insertion point</param>
		/// <param name="iSection">The 0-based index of the Scripture section in which to put the
		/// insertion point</param>
		/// <param name="tag">Indicates whether the picture ORC is in the section
		/// Heading or Content, the book title</param>
		/// <param name="iPara">The 0-based index of the paragraph containing the ORC</param>
		/// <param name="ichOrcPos">The character position of the orc in the paragraph.</param>
		/// <param name="startCharacter">The 0-based index of the character at which the
		/// selection begins (or before which the insertion point is to be placed if
		/// startCharacter == endCharacter)</param>
		/// <param name="endCharacter">The character location to end the selection</param>
		/// <exception cref="Exception">Requested selection could not be made in the picture
		/// caption.</exception>
		/// ------------------------------------------------------------------------------------
		public void MakeSelectionInPictureCaption(int iBook, int iSection, int tag,
			int iPara, int ichOrcPos, int startCharacter, int endCharacter)
		{
			CheckDisposed();

			if (Callbacks == null || Callbacks.EditedRootBox == null)
				throw new Exception("Requested selection could not be made in the picture caption.");

			Debug.Assert(tag == (int)ScrSection.ScrSectionTags.kflidHeading ||
				tag == (int)ScrSection.ScrSectionTags.kflidContent ||
				tag == (int)ScrBook.ScrBookTags.kflidTitle);
			Debug.Assert(!IsBackTranslation, "ENHANCE: This code not designed to make a selection in the BT of a picture caption");

			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = ((ITeView)Control).LocationTracker.GetLevelCount(tag) + 1;
			int levelForPara = LocationTrackerImpl.GetLevelIndexForTag(
				(int)StText.StTextTags.kflidParagraphs, StVc.ContentTypes.kctNormal) + 1;
			int levelForCaption = LocationTrackerImpl.GetLevelIndexForTag(
				(int)CmPicture.CmPictureTags.kflidCaption, StVc.ContentTypes.kctNormal);
			selHelper.LevelInfo[levelForCaption].ihvo = -1;
			selHelper.LevelInfo[levelForCaption].ich = ichOrcPos;
			selHelper.LevelInfo[levelForCaption].tag = (int)StTxtPara.StTxtParaTags.kflidContents;
			selHelper.Ws = m_cache.DefaultVernWs;
			selHelper.LevelInfo[levelForPara].tag = (int)StText.StTextTags.kflidParagraphs;
			selHelper.LevelInfo[levelForPara].ihvo = iPara;
			selHelper.LevelInfo[levelForPara + 1].tag = tag;

			((ITeView)Control).LocationTracker.SetBookAndSection(selHelper,
				SelectionHelper.SelLimitType.Anchor, iBook,
				tag == (int)ScrBook.ScrBookTags.kflidTitle ? -1 : iSection);

			selHelper.AssocPrev = true;
			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selHelper.LevelInfo);

			// Prepare to move the IP to the specified character in the paragraph.
			selHelper.IchAnchor = startCharacter;
			selHelper.IchEnd = endCharacter;
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, (int)CmPicture.CmPictureTags.kflidCaption);
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, (int)CmPicture.CmPictureTags.kflidCaption);

			// Now that all the preparation to set the IP is done, set it.
			IVwSelection vwsel = selHelper.SetSelection(Callbacks.EditedRootBox.Site, true,
				true, VwScrollSelOpts.kssoDefault);

			if (vwsel == null)
				throw new Exception("Requested selection could not be made in the picture caption.");

			Application.DoEvents(); // REVIEW: Do we need this? Why?
		}
Ejemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Scroll to a footnote
		/// </summary>
		/// <param name="iBook">Index of the book's hvo</param>
		/// <param name="iFootnote">Index of the footnote's hvo</param>
		/// <param name="ich">The offset of the character position in the footnote's (first)
		/// paragraph to use as the insertion point.</param>
		/// ------------------------------------------------------------------------------------
		public void ScrollToFootnote(int iBook, int iFootnote, int ich)
		{
			CheckDisposed();

			if (Control == null || !(Control is SimpleRootSite))
				return;

			int paraLevel = 0;
			int footnoteLevel = 1;
			int bookLevel = 2;

			// create selection pointing to this footnote
			SelectionHelper selHelper = new SelectionHelper();
			selHelper.AssocPrev = false;

			// Set up selection for a back translation
			if (ContentType == StVc.ContentTypes.kctSimpleBT)
			{
				paraLevel++;
				footnoteLevel++;
				bookLevel++;
				selHelper.NumberOfLevels = 4;
				selHelper.LevelInfo[0].tag = -1;
				selHelper.LevelInfo[0].ihvo = 0;
				selHelper.LevelInfo[0].cpropPrevious = 2;
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
					CmTranslationTags.kflidTranslation);
			}
			else if (ContentType == StVc.ContentTypes.kctSegmentBT)
			{
				// In all segment BT views, under the paragraph there is a segment, and under that
				// an object which is the free translation itself.
				paraLevel++;
				footnoteLevel++;
				bookLevel++;
				selHelper.NumberOfLevels = 4;
				selHelper.LevelInfo[0].ihvo = 0; // Segment index
				selHelper.LevelInfo[0].tag = StTxtParaTags.kflidSegments;
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
					SegmentTags.kflidFreeTranslation);
			}
			else // Selection is in vernacular
			{
				selHelper.NumberOfLevels = 3;
				selHelper.TextPropId = StTxtParaTags.kflidContents;
			}

			selHelper.LevelInfo[paraLevel].tag = StTextTags.kflidParagraphs;
			selHelper.LevelInfo[paraLevel].ihvo = 0;
			selHelper.LevelInfo[footnoteLevel].tag = ScrBookTags.kflidFootnotes;
			selHelper.LevelInfo[footnoteLevel].ihvo = iFootnote;
			selHelper.LevelInfo[bookLevel].tag = BookFilter.Tag;
			selHelper.LevelInfo[bookLevel].ihvo = iBook;
			selHelper.IchAnchor = ich;
			selHelper.IchEnd = ich;

			if (DeferSelectionUntilEndOfUOW)
			{
				// We are within a unit of work, so setting the selection will not work now.
				// we request that a selection be made after the unit of work.
				Debug.Assert(!selHelper.IsRange,
					"Currently, a selection made during a unit of work can only be an insertion point.");
				selHelper.SetIPAfterUOW(EditedRootBox.Site);
				return;
			}

			IVwSelection vwsel = selHelper.SetSelection((SimpleRootSite)Control, true, true, VwScrollSelOpts.kssoTop);
			if (vwsel == null)
			{
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, SimpleRootSite.kTagUserPrompt);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, SimpleRootSite.kTagUserPrompt);
				selHelper.SetSelection((SimpleRootSite)Control, true, true);
			}
		}
Ejemplo n.º 7
0
		public void DeleteFootnoteFromContextMenuRangeSelection()
		{
			SelectionHelper selHelper = new SelectionHelper();
			selHelper.AssocPrev = true;
			selHelper.NumberOfLevels = 3;

			SelLevInfo[] anchorLevInfo = new SelLevInfo[3];
			anchorLevInfo[2].tag = m_footnoteView.BookFilter.Tag;
			anchorLevInfo[2].ihvo = 1;
			anchorLevInfo[1].tag = ScrBookTags.kflidFootnotes;
			anchorLevInfo[1].ihvo = 2;
			anchorLevInfo[0].tag = StTextTags.kflidParagraphs;
			anchorLevInfo[0].ihvo = 0;
			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, anchorLevInfo);
			selHelper.IchAnchor = 1;
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, StTxtParaTags.kflidContents);

			SelLevInfo[] endLevInfo = new SelLevInfo[3];
			endLevInfo[2].tag = m_footnoteView.BookFilter.Tag;
			endLevInfo[2].ihvo = 1;
			endLevInfo[1].tag = ScrBookTags.kflidFootnotes;
			endLevInfo[1].ihvo = 6;
			endLevInfo[0].tag = StTextTags.kflidParagraphs;
			endLevInfo[0].ihvo = 0;
			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, endLevInfo);
			selHelper.IchEnd = 7;
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, StTxtParaTags.kflidContents);

			// Now that all the preparation to set the selection is done, set it.
			selHelper.SetSelection(m_footnoteView, true, true);
			Application.DoEvents();

			// First get the footnotes we're deleting.
			IScrFootnote[] footnotes = new IScrFootnote[5];
			Guid[] guidFootnotes = new Guid[5];
			IStTxtPara[] paras = new IStTxtPara[5];
			for (int i = 0; i < 5; i++)
			{
				footnotes[i] = Cache.ServiceLocator.GetInstance<IScrFootnoteRepository>().GetObject(m_Jude.FootnotesOS[i + 2].Hvo);
				guidFootnotes[i] = footnotes[i].Guid;
				paras[i] = footnotes[i].ParaContainingOrcRA;
			}

			m_footnoteView.DeleteFootnote();

			foreach (IScrFootnote footnote in footnotes)
				Assert.IsFalse(footnote.IsValidObject);

			// now make sure that we don't find the footnote markers
			for (int i = 0; i < 5; i++)
			{
				VerifyRemovedFootnoteMarker(paras[i], guidFootnotes[i]);
				VerifyRemovedFootnoteMarker(paras[i], guidFootnotes[i], m_wsEn);
				VerifyRemovedFootnoteMarker(paras[i], guidFootnotes[i], m_wsDe);
			}
		}
Ejemplo n.º 8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Low-level implementation of insert verse number.
		/// </summary>
		/// <param name="selHelper">the given SelectionHelper</param>
		/// ------------------------------------------------------------------------------------
		public void InsertVerseNumber(SelectionHelper selHelper)
		{
			CheckDisposed();
			Debug.Assert(selHelper != null);
			Debug.Assert(!selHelper.IsRange || IsSelectionInPrompt(selHelper));

			// Get the details about the current selection
			int ichSelOrig; //the character offset of the selection in the ITsString
			int hvoObj; //the id of the object the selection is in (StTxtPara or CmTranslation)
			int propTag; //property tag of object
			ITsString tssSel; //ITsString containing the selection
			int wsAlt; //the WS of the multiString alt, if selection is in a back translation
			ichSelOrig = GetSelectionInfo(selHelper, out hvoObj, out propTag, out tssSel, out wsAlt);

			// The current run is a chapter number and IP is either at the beginning of the line or
			// in the middle of the chapter number, we need to jump past it to insert the verse number
			// otherwise it will insert it before the chapter number or in the chapter number.
			int iRun = tssSel.get_RunAt(ichSelOrig);
			if (tssSel.Style(iRun) == ScrStyleNames.ChapterNumber &&
				(ichSelOrig == 0 || ichSelOrig > tssSel.get_MinOfRun(iRun)))
				ichSelOrig = tssSel.get_LimOfRun(iRun);

			// Adjust the insertion position to the beginning of a word - not in the middle
			//  (may move to an existing verse number too)
			int ichWord = tssSel.FindWordBoundary(ichSelOrig, UnicodeCharProps, ScrStyleNames.ChapterAndVerse);

			//			TomB and MarkB have decided we won't do this, at least for now
			//			// If the start of the Bt does not match the vernacular, adjust it if required.
			//			if (ichWord > 0)
			//				cInsDel = SetVerseAtStartOfBtIfNeeded();
			//			ichWord += cInsDel; //adjust

			// some key variables set by Update or Insert methods, etc
			string sVerseNumIns = null; // will hold the verse number string we inserted; could be
			//   a simple number, a verse bridge, or the end number added to a bridge
			string sChapterNumIns = null; // will hold chapter number string inserted or null if none
			int ichLimIns = -1; //will hold the end of the new chapter/verse numbers we update or insert

			// Is ichWord in or next to a verse number? (if so, get its ich range)
			bool fCheckForChapter = (wsAlt != 0); //check for chapter in BT only
			int ichMin; // min of the verse number run, if we are on one
			int ichLim; // lim of the verse number run, if we are on one
			bool fFoundExistingRef =
				InReference(tssSel, ichWord, fCheckForChapter, out ichMin, out ichLim);

			SelLevInfo paraInfo = selHelper.GetLevelInfoForTag(StTextTags.kflidParagraphs);
			IScrTxtPara para = m_cache.ServiceLocator.GetInstance<IScrTxtParaRepository>().GetObject(paraInfo.hvo);

			// If we moved the selection forward (over spaces or punctuation) to an
			//  existing verse number ...
			if (fFoundExistingRef && (ichSelOrig < ichWord))
			{
				//Attempt to insert a verse number at the IP, if one is missing there.
				// if selection is in vernacular...
				if (propTag == StTxtParaTags.kflidContents)
				{
					// Insert missing verse number in vernacular
					para.InsertMissingVerseNumberInVern(ichSelOrig, ichWord, out sVerseNumIns,
						out ichLimIns);
				}
			}

			// if a verse number was not inserted, sVerseNumIns is null
			// If no verse number inserted yet...
			if (sVerseNumIns == null)
			{
				if (fFoundExistingRef)
				{
					//We must update the existing verse number at ichWord
					// is selection in vern or BT?
					if (propTag == StTxtParaTags.kflidContents)
					{
						// Update verse number in vernacular
						para.UpdateExistingVerseNumberInVern(ichMin, ichLim, out sVerseNumIns,
							out ichLimIns);
					}
					else
					{
						//Update verse number in back translation
						para.UpdateExistingVerseNumberInBt(wsAlt, ichMin, ichLim, out sVerseNumIns,
							out sChapterNumIns, out ichLimIns);
					}
				}
				else
				{
					// We're NOT on an existing verse number, so insert the next appropriate one.
					// is selection in vern or BT?
					if (propTag == StTxtParaTags.kflidContents)
					{
						para.InsertNextVerseNumberInVern(ichWord, out sVerseNumIns, out ichLimIns);
					}
					else
					{
						para.InsertNextVerseNumberInBt(wsAlt, ichWord, out sVerseNumIns,
							out sChapterNumIns, out ichLimIns);
						selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
							CmTranslationTags.kflidTranslation);
						selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
							CmTranslationTags.kflidTranslation);
					}
				}
			}

			if (sVerseNumIns == null)
			{
				MiscUtils.ErrorBeep(); // No verse number inserted or updated
				return;
			}

			// set new IP behind the verse number
			selHelper.IchAnchor = ichLimIns;
			selHelper.IchEnd = ichLimIns;
			selHelper.AssocPrev = true;
			selHelper.SetIPAfterUOW();

			// Remove any duplicate chapter/verse numbers following the new verse number.
			para.RemoveDuplicateVerseNumbers(wsAlt, sChapterNumIns, sVerseNumIns, ichLimIns);
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Moves the cursor to the specified position in the specified cell.
		/// </summary>
		/// <param name="cellId">The cell id.</param>
		/// <param name="cellIndex">Index of the item in the cell.</param>
		/// <param name="initial">if <c>true</c> move the cursor to the beginning of the specified item, otherwise it is moved to the end</param>
		/// <param name="editable">if <c>true</c> move the cursor to the first editable position</param>
		/// <param name="install">if <c>true</c> install the selection</param>
		/// <returns>The new selection</returns>
		protected IVwSelection SelectAt(int cellId, int cellIndex, bool initial, bool editable, bool install)
		{
			SelLevInfo[] levels = GetLevelInfo(cellId, cellIndex);
			if (levels == null)
			{
				int count = GetCellCount(cellId);
				if (count == 0)
				{
					SelectionHelper newSel = new SelectionHelper();
					newSel.SetTextPropId(SelectionHelper.SelLimitType.Anchor, GetFlid(cellId));
					return newSel.SetSelection(m_view, install, false);
				}
				else
				{
					levels = GetLevelInfo(cellId, initial ? 0 : count - 1);
				}
			}

			return m_view.RootBox.MakeTextSelInObj(0, levels.Length, levels, 0, null, initial, editable, false, false, install);
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Moves the cursor to the specified position in the specified cell.
		/// </summary>
		/// <param name="ctxt">The context.</param>
		/// <param name="index">Index of the item in the cell.</param>
		/// <param name="initial">if <c>true</c> move the cursor to the beginning of the specified item, otherwise it is moved to the end</param>
		/// <param name="editable">if <c>true</c> move the cursor to the first editable position</param>
		/// <param name="install">if <c>true</c> install the selection</param>
		/// <returns>The new selection</returns>
		public IVwSelection SelectAt(object ctxt, int index, bool initial, bool editable, bool install)
		{
			SelLevInfo[] levels = m_patternControl.GetLevelInfo(ctxt, index);
			if (levels == null)
			{
				int count = m_patternControl.GetContextCount(ctxt);
				if (count == 0)
				{
					var newSel = new SelectionHelper();
					newSel.SetTextPropId(SelectionHelper.SelLimitType.Anchor, m_patternControl.GetFlid(ctxt));
					return newSel.SetSelection(this, install, false);
				}
				levels = m_patternControl.GetLevelInfo(ctxt, initial ? 0 : count - 1);
			}

			return RootBox.MakeTextSelInObj(0, levels.Length, levels, 0, null, initial, editable, false, false, install);
		}
Ejemplo n.º 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Goes to the text referenced in the ScrScriptureNote. If it does not find the text,
		/// it makes the closest selection to the referenced text that it can.
		/// </summary>
		/// <param name="note">the note containing the Scripture reference to find</param>
		/// <param name="sendSyncMsg"><c>true</c> to not send a focus sychronization message
		/// when the selection is changed by going to the scripture ref.</param>
		/// ------------------------------------------------------------------------------------
		public void GoToScrScriptureNoteRef(IScrScriptureNote note, bool sendSyncMsg)
		{
			// TODO (TE-1729): Use this method correctly from Annotations view.

			ScrReference scrRef = new ScrReference(note.BeginRef, m_scr.Versification);
			IScrBook book = BookFilter.GetBookByOrd(scrRef.Book);
			if (book == null)
				return;

			int iBook = BookFilter.GetBookIndex(book);

			using (new IgnoreSynchMessages(TheMainWnd))
			{
				if (note.Flid == CmPictureTags.kflidCaption)
				{
					SelectCitedTextInPictureCaption(iBook, note);
					return;
				}

				int ichStart, ichEnd;
				string citedText = note.CitedText;
				ITsString citedTextTss = note.CitedTextTss;
				IStTxtPara para = note.BeginObjectRA as IStTxtPara;
				if (para != null && para.OwnerOfClass<IScrDraft>() == null)
				{
					if (para.Owner is IStFootnote)
					{
						// Make selection in footnote.
						if (TextAtExpectedLoc(para.Contents.Text, citedText, note.BeginOffset, note.EndOffset))
						{
							// Select text in footnote.
							IStFootnote footnote = (IStFootnote)para.Owner;

							SelectionHelper selHelper = new SelectionHelper();
							selHelper.AssocPrev = false;
							selHelper.NumberOfLevels = 3;
							selHelper.LevelInfo[2].tag = BookFilter.Tag;
							selHelper.LevelInfo[2].ihvo = iBook;
							selHelper.LevelInfo[1].tag = ScrBookTags.kflidFootnotes;
							selHelper.LevelInfo[1].ihvo = footnote.IndexInOwner;
							selHelper.LevelInfo[0].tag = StTextTags.kflidParagraphs;
							selHelper.LevelInfo[0].ihvo = 0;

							// Prepare to move the IP to the specified character in the paragraph.
							selHelper.IchAnchor = note.BeginOffset;
							selHelper.IchEnd = note.EndOffset;
							selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, StTxtParaTags.kflidContents);
							selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, StTxtParaTags.kflidContents);

							// Now that all the preparation to set the IP is done, set it.
							selHelper.SetSelection(Callbacks.EditedRootBox.Site, true, true);
						}
						return;
					}

					// Make selection in Scripture text
					if (TextAtExpectedLoc(para.Contents.Text, citedText, note.BeginOffset, note.EndOffset))
					{
						SelectRangeOfChars(iBook, para, note.BeginOffset, note.EndOffset);
						return;
					}

					if (scrRef.Verse == 0)
					{
						// Either a missing chapter number or something in intro material.
						// Not much chance of finding it by reference (even if the chapter number
						// has been added, we never find the 0th verse, and 99% of the time that
						// chapter number would have been added to the same paragraph where it
						// was missing in the first place), so just try to find the text in the
						// paragraph, if it still exists.
						if (string.IsNullOrEmpty(citedText))
						{
							SelectRangeOfChars(iBook, para, note.BeginOffset, note.BeginOffset);
							return;
						}

						// The text may be null if the paragraph only contains the prompt. TE-8315
						if (para.Contents.Text != null)
						{
							int i = para.Contents.Text.IndexOf(citedText);
							if (i >= 0)
							{
								SelectRangeOfChars(iBook, para, i, i + citedText.Length);
								return;
							}
						}
					}
				}


				// A selection could not be made at the specified location. Attempt to go to
				// the specified verse and then try to find the text.

				// REVIEW (TimS): Why do we call GotoVerse here when we select the characters
				// down below? We might consider doing this only if we fail down below.
				if (sendSyncMsg)
					GotoVerse(scrRef);
				else
					GotoVerse_WithoutSynchMsg(scrRef);

				int iSection, iPara;
				if (citedText != null && FindTextInVerse(m_scr, citedTextTss, scrRef, false, out iSection,
					out iPara, out ichStart, out ichEnd))
				{
					// We found the text in the verse at a different character offset.
					SelectRangeOfChars(iBook, iSection, iPara, ichStart, ichEnd);
				}
				else if (note.BeginOffset > 0 && para != null &&
					IsOffsetValidLoc(para.Contents.Text, note.BeginOffset))
				{
					// We couldn't find the cited text at the specified offset, nor anywhere
					// in the paragraph. Therefore, just set the IP at the begin offset.
					SelectRangeOfChars(iBook, para, note.BeginOffset, note.BeginOffset);
				}
			}
		}
Ejemplo n.º 12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a range selection (adapted from TePrintLayout.cs).
		/// </summary>
		/// <param name="rootbox">The rootbox.</param>
		/// <param name="iPara">The 0-based index of the paragraph in which to put the insertion
		/// point</param>
		/// <param name="startCharacter">The 0-based index of the character at which the
		/// selection begins (or before which the insertion point is to be placed if
		/// startCharacter == endCharacter)</param>
		/// <param name="endCharacter">The character location to end the selection</param>
		/// <returns>The selection helper</returns>
		/// ------------------------------------------------------------------------------------
		private SelectionHelper SelectRangeOfChars(IVwRootBox rootbox, int iPara,
			int startCharacter, int endCharacter)
		{
			if (rootbox == null)
				return null;  // can't make a selection

			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = 1;

			selHelper.LevelInfo[0].ihvo = iPara;
			selHelper.LevelInfo[0].tag = StTextTags.kflidParagraphs;
			selHelper.AssocPrev = true;

			selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selHelper.LevelInfo);

			// Prepare to move the IP to the specified character in the paragraph.
			selHelper.IchAnchor = startCharacter;
			selHelper.IchEnd = endCharacter;
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, StTxtParaTags.kflidContents);
			selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, StTxtParaTags.kflidContents);

			// Now that all the preparation to set the IP is done, set it.
			IVwSelection vwsel = selHelper.SetSelection(rootbox.Site, true, false,
				VwScrollSelOpts.kssoDefault);

			Assert.IsNotNull(vwsel);
			Application.DoEvents();

			return selHelper;
		}
Ejemplo n.º 13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets up the specifed SelectionHelper for the specified paragraph and StText.
		/// </summary>
		/// <param name="helper">The SelectionHelper.</param>
		/// <param name="text">The StText.</param>
		/// <param name="para">The para.</param>
		/// <param name="limit">The limit.</param>
		/// <param name="view">The view</param>
		/// ------------------------------------------------------------------------------------
		private void SetupSelectionFor(SelectionHelper helper, IStText text, IStTxtPara para,
			SelectionHelper.SelLimitType limit, FwRootSite view)
		{
			Debug.Assert((view is DraftView && ((DraftView)view).TeEditingHelper != null) ||
				(view is FootnoteView && ((FootnoteView)view).EditingHelper != null));

			helper.SetTextPropId(limit, StTxtParaTags.kflidContents);

			if (view is DraftView)
			{
				DraftView draftView = (DraftView)view;

				if ((text.OwningFlid == ScrSectionTags.kflidContent ||
					text.OwningFlid == ScrSectionTags.kflidHeading))
				{
					// text belongs to section heading or contents
					IScrSection section = (IScrSection)text.Owner;
					Debug.Assert(section.OwningFlid == ScrBookTags.kflidSections);

					helper.SetNumberOfLevels(limit, 4);
					SelLevInfo[] info = helper.GetLevelInfo(limit);
					info[0].ihvo = para.IndexInOwner;
					info[0].tag = StTextTags.kflidParagraphs;
					info[1].ihvo = 0;
					info[1].tag = text.OwningFlid;
					info[2].ihvo = section.IndexInOwner;
					info[2].tag = ScrBookTags.kflidSections;
					info[3].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex((IScrBook)section.Owner);
					info[3].tag = draftView.TeEditingHelper.BookFilter.Tag;
				}
				else
				{
					// text belongs to a book title
					Debug.Assert(text.OwningFlid == ScrBookTags.kflidTitle);
					IScrBook book = (IScrBook)text.Owner;

					helper.SetNumberOfLevels(limit, 3);
					SelLevInfo[] info = helper.GetLevelInfo(limit);
					info[0].ihvo = para.IndexInOwner;
					info[0].tag = StTextTags.kflidParagraphs;
					info[1].ihvo = 0;
					info[1].tag = text.OwningFlid;
					info[2].ihvo = draftView.TeEditingHelper.BookFilter.GetBookIndex(book);
					info[2].tag = draftView.TeEditingHelper.BookFilter.Tag;
				}
			}
			else if (view is FootnoteView && text.OwningFlid == ScrBookTags.kflidFootnotes)
			{
				// text belongs to a footnote
				FootnoteView footnoteView = (FootnoteView)view;
				IStFootnote footnote = (IStFootnote)para.Owner;
				IScrBook book = (IScrBook)text.Owner;

				helper.SetNumberOfLevels(limit, 3);
				SelLevInfo[] info = helper.GetLevelInfo(limit);
				info[0].hvo = text.Hvo;
				info[0].tag = StTextTags.kflidParagraphs;
				info[1].hvo = footnote.Hvo;
				info[1].ihvo = footnote.IndexInOwner;
				info[1].tag = ScrBookTags.kflidFootnotes;
				info[2].hvo = book.Hvo;
				info[2].ihvo = footnoteView.BookFilter.GetBookIndex(book);
				info[2].tag = footnoteView.BookFilter.Tag;
				info[0].ich = info[1].ich = info[2].ich = -1;
			}
		}
Ejemplo n.º 14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Tests the both the anchor and the end of the specified selection. If its located in
		/// a book title or a section head, then it sets the properties to a user prompt.
		/// </summary>
		/// <param name="helper">The selection</param>
		/// <param name="paraAnchor">The paragraph at the anchor.</param>
		/// <param name="paraEnd">The paragraph at the end.</param>
		/// ------------------------------------------------------------------------------------
		private void AdjustSelectionForPrompt(SelectionHelper helper, IStTxtPara paraAnchor,
			IStTxtPara paraEnd)
		{
			SelectionHelper.SelLimitType limit = SelectionHelper.SelLimitType.Anchor;
			if ((helper.IsFlidInLevelInfo(ScrSectionTags.kflidHeading, limit) ||
				helper.IsFlidInLevelInfo(ScrBookTags.kflidTitle, limit)) &&
				paraAnchor.Contents.Length == 0)
			{
				helper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
					SimpleRootSite.kTagUserPrompt);
			}

			limit = SelectionHelper.SelLimitType.End;
			if ((helper.IsFlidInLevelInfo(ScrSectionTags.kflidHeading, limit) ||
				helper.IsFlidInLevelInfo(ScrBookTags.kflidTitle, limit)) &&
				paraEnd.Contents.Length == 0)
			{
				helper.SetTextPropId(SelectionHelper.SelLimitType.End,
					SimpleRootSite.kTagUserPrompt);
			}
		}
Ejemplo n.º 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Ensures the annotation is mostly visible by making an uninstalled selection
		/// toward the end of the modified date.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal void EnsureNoteIsVisible(TeNotesVc vc, int bookIndex, int iAnnotation,
			IVwRootSite notesDataEntryView)
		{
			SelectionHelper selHelper = new SelectionHelper();
			selHelper.NumberOfLevels = 2;
			selHelper.LevelInfo[0].cpropPrevious = 0;
			selHelper.LevelInfo[0].ich = -1;
			selHelper.LevelInfo[0].ihvo = iAnnotation;
			selHelper.LevelInfo[0].tag = vc.NotesSequenceHandler.Tag;
			selHelper.LevelInfo[0].ws = 0;
			selHelper.LevelInfo[1].cpropPrevious = 0;
			selHelper.LevelInfo[1].ich = -1;
			selHelper.LevelInfo[1].ihvo = bookIndex;
			selHelper.LevelInfo[1].tag = (int)Scripture.ScriptureTags.kflidBookAnnotations;
			selHelper.LevelInfo[1].ws = 0;
			selHelper.AssocPrev = false;

			// Put the selection at the end of the shortest possible date value. It doesn't
			// have to be right at the end, but the closer it is, the more reliable it will
			// be that it is fully scrolled into view.
			selHelper.IchAnchor = 8;

			selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
				(int)CmAnnotation.CmAnnotationTags.kflidDateModified);

			selHelper.SetSelection(notesDataEntryView, false, true, VwScrollSelOpts.kssoDefault);
		}
Ejemplo n.º 16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the displayed text for a footnote.
		/// </summary>
		/// <param name="iBook">Index of the book the footnote is in</param>
		/// <param name="iFootnote">Index of the footnote</param>
		/// <param name="footnote">The footnote object</param>
		/// <returns>The TsString representing the text of the footnote, including any displayed
		/// marker, reference, etc.</returns>
		/// ------------------------------------------------------------------------------------
		public ITsString GetDisplayedTextForFootnote(int iBook, int iFootnote,
			StFootnote footnote)
		{
			SelectionHelper helper = new SelectionHelper();

			// Create selection in footnote marker
			SelLevInfo[] anchorLevInfo = new SelLevInfo[4];
			anchorLevInfo[3].tag = BookFilter.Tag;
			anchorLevInfo[3].ihvo = iBook;
			anchorLevInfo[2].tag = (int)ScrBook.ScrBookTags.kflidFootnotes;
			anchorLevInfo[2].ihvo = iFootnote;
			anchorLevInfo[1].tag = (int)StText.StTextTags.kflidParagraphs;
			anchorLevInfo[1].ihvo = 0;
			anchorLevInfo[0].tag = -1;
			anchorLevInfo[0].ihvo = 0;
			helper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, anchorLevInfo);
			helper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
				(int)VwSpecialAttrTags.ktagGapInAttrs);
			helper.IchAnchor = 0;

			SelLevInfo[] endLevInfo = new SelLevInfo[3];
			endLevInfo[2].tag = BookFilter.Tag;
			endLevInfo[2].ihvo = iBook;
			endLevInfo[1].tag = (int)ScrBook.ScrBookTags.kflidFootnotes;
			endLevInfo[1].ihvo = iFootnote;
			endLevInfo[0].tag = (int)StText.StTextTags.kflidParagraphs;
			endLevInfo[0].ihvo = 0;
			helper.SetLevelInfo(SelectionHelper.SelLimitType.End, endLevInfo);
			helper.SetTextPropId(SelectionHelper.SelLimitType.End,
				(int)StTxtPara.StTxtParaTags.kflidContents);
			string footnoteText = ((StTxtPara)footnote.ParagraphsOS[0]).Contents.Text;
			helper.IchEnd = footnoteText.Length;

			helper.SetSelection(this, true, true);

			IVwSelection sel = RootBox.Selection;
			ITsString tss;
			sel.GetSelectionString(out tss, string.Empty);
			return tss;
		}
Ejemplo n.º 17
0
		private void SetupTranslationPrompt(SelectionHelper helper, int flid)
		{
			IVwSelection sel;
			m_vc.SetActiveFreeform(helper.LevelInfo[0].hvo, flid, helper.Ws, helper.NumberOfPreviousProps);
			helper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, kTagUserPrompt);
			helper.SetTextPropId(SelectionHelper.SelLimitType.End, kTagUserPrompt);
			helper.NumberOfPreviousProps = 0; // only ever one occurrence of prompt.
			helper.SetNumberOfPreviousProps(SelectionHelper.SelLimitType.End, 0);
			// Even though the helper method is called MakeRangeSelection, it will initially make
			// an IP, because we haven't set any different offset for the end.
			// Since it's at the start of the prompt, we need it to associate with the prompt,
			// not the preceding (zero width direction-control) character.
			helper.AssocPrev = false;
			try
			{
				sel = helper.MakeRangeSelection(m_rootb, true);
				sel.ExtendToStringBoundaries();
			}
			// Prevent the crash described in LT-9399 by swallowing the exception.
			catch (Exception exc)
			{
				if (exc != null)
					Debug.WriteLine(String.Format(
						"InterlinDocChild.SelectionChanged() trying to display prompt for empty translation: {0}", exc.Message));
			}
		}
Ejemplo n.º 18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Scroll to a footnote
		/// </summary>
		/// <param name="iBook">Index of the book's hvo</param>
		/// <param name="iFootnote">Index of the footnote's hvo</param>
		/// <param name="ich">The offset of the character position in the footnote's (first)
		/// paragraph to use as the insertion point.</param>
		/// ------------------------------------------------------------------------------------
		public void ScrollToFootnote(int iBook, int iFootnote, int ich)
		{
			CheckDisposed();

			if (Control == null || !(Control is SimpleRootSite))
				return;

			int paraLevel = 0;
			int footnoteLevel = 1;
			int bookLevel = 2;

			// create selection pointing to this footnote
			SelectionHelper selHelper = new SelectionHelper();
			selHelper.AssocPrev = false;

			if (IsBackTranslation)
			{
				// Set up selection for a back translation
				paraLevel++;
				footnoteLevel++;
				bookLevel++;
				selHelper.NumberOfLevels = 4;
				selHelper.LevelInfo[0].tag = -1;
				selHelper.LevelInfo[0].ihvo = 0;
				selHelper.LevelInfo[0].cpropPrevious = 2;
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor,
					(int)CmTranslation.CmTranslationTags.kflidTranslation);
			}
			else // Selection is in vernacular
				selHelper.NumberOfLevels = 3;

			selHelper.LevelInfo[paraLevel].tag = (int)StText.StTextTags.kflidParagraphs;
			selHelper.LevelInfo[paraLevel].ihvo = 0;
			selHelper.LevelInfo[footnoteLevel].tag = (int)ScrBook.ScrBookTags.kflidFootnotes;
			selHelper.LevelInfo[footnoteLevel].ihvo = iFootnote;
			selHelper.LevelInfo[bookLevel].tag = BookFilter.Tag;
			selHelper.LevelInfo[bookLevel].ihvo = iBook;
			selHelper.IchAnchor = ich;
			selHelper.IchEnd = ich;

			IVwSelection vwsel =
				selHelper.SetSelection((SimpleRootSite)Control, true, true, VwScrollSelOpts.kssoTop);
			if (vwsel == null)
			{
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.Anchor, SimpleRootSite.kTagUserPrompt);
				selHelper.SetTextPropId(SelectionHelper.SelLimitType.End, SimpleRootSite.kTagUserPrompt);
				vwsel = selHelper.SetSelection((SimpleRootSite)Control, true, true);
			}
		}