Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle a problem deletion. No problem deletions currently handled, beep and
        /// return Abort so that default behavior is not tried.
        /// </summary>
        /// <param name="sel"></param>
        /// <param name="dpt"></param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
                                                            VwDelProbType dpt)
        {
            CheckDisposed();

            MiscUtils.ErrorBeep();
            return(VwDelProbResponse.kdprAbort);
        }
Ejemplo n.º 2
0
        public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
                                                            VwDelProbType dpt)
        {
            CheckDisposed();
            int cvsli;
            int hvoObj;

            if (!CheckForValidDelete(sel, out cvsli, out hvoObj))
            {
                return(VwDelProbResponse.kdprAbort);
            }

            return(DeleteObjectFromVector(sel, cvsli, hvoObj));
        }
Ejemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// The user has attempted to delete something which the system does not inherently
        /// know how to delete. The dpt argument indicates the type of problem.
        /// </summary>
        /// <param name="sel">The selection</param>
        /// <param name="dpt">Problem type</param>
        /// <returns>response value</returns>
        /// ------------------------------------------------------------------------------------
        public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
                                                            VwDelProbType dpt)
        {
            CheckDisposed();

            switch (dpt)
            {
            case VwDelProbType.kdptBsAtStartPara:
            case VwDelProbType.kdptDelAtEndPara:
            case VwDelProbType.kdptNone:
                return(VwDelProbResponse.kdprDone);

            case VwDelProbType.kdptBsReadOnly:
            case VwDelProbType.kdptComplexRange:
            case VwDelProbType.kdptDelReadOnly:
            case VwDelProbType.kdptReadOnly:
                return(VwDelProbResponse.kdprFail);
            }
            return(VwDelProbResponse.kdprAbort);
        }
Ejemplo n.º 4
0
		/// <summary>
		/// This handles deleting the "owning" sense or entry from a calendar type lex
		/// reference by posting a message instead of simply removing the sense or entry from
		/// the reference vector.  This keeps things nice and tidy on the screen, and behaving
		/// like users would (or ought to) expect.  See LT-4114.
		/// </summary>
		/// <param name="sel"></param>
		/// <param name="dpt"></param>
		/// <returns></returns>
		public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
			VwDelProbType dpt)
		{
			CheckDisposed();

			int cvsli;
			int hvoObj;
			if (!CheckForValidDelete(sel, out cvsli, out hvoObj))
			{
				return VwDelProbResponse.kdprAbort;
			}
			else if (hvoObj == m_hvoDisplayParent)
			{
				// We need to handle this the same way as the delete command in the slice menu,
				// but can't do it directly because we've stacked up an undo handler.
				m_mediator.PostMessage("DataTreeDelete", null);
				return VwDelProbResponse.kdprDone;
			}
			else
			{
				return DeleteObjectFromVector(sel, cvsli, hvoObj);
			}
		}
Ejemplo n.º 5
0
        /// <summary>
        /// This handles deleting the "owning" sense or entry from a calendar type lex
        /// reference by posting a message instead of simply removing the sense or entry from
        /// the reference vector.  This keeps things nice and tidy on the screen, and behaving
        /// like users would (or ought to) expect.  See LT-4114.
        /// </summary>
        /// <param name="sel"></param>
        /// <param name="dpt"></param>
        /// <returns></returns>
        public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
                                                            VwDelProbType dpt)
        {
            CheckDisposed();

            int cvsli;
            int hvoObj;

            if (!CheckForValidDelete(sel, out cvsli, out hvoObj))
            {
                return(VwDelProbResponse.kdprAbort);
            }
            else if (hvoObj == m_hvoDisplayParent)
            {
                // We need to handle this the same way as the delete command in the slice menu,
                // but can't do it directly because we've stacked up an undo handler.
                m_mediator.PostMessage("DataTreeDelete", null);
                return(VwDelProbResponse.kdprDone);
            }
            else
            {
                return(DeleteObjectFromVector(sel, cvsli, hvoObj));
            }
        }
Ejemplo n.º 6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle a problem deletion. No problem deletions currently handled, beep and
		/// return Abort so that default behavior is not tried.
		/// </summary>
		/// <param name="sel"></param>
		/// <param name="dpt"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
			VwDelProbType dpt)
		{
			CheckDisposed();

			MiscUtils.ErrorBeep();
			return VwDelProbResponse.kdprAbort;
		}
Ejemplo n.º 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// The user has attempted to delete something which the system does not inherently
		/// know how to delete. The dpt argument indicates the type of problem.
		/// </summary>
		/// <param name="sel">The selection</param>
		/// <param name="dpt">Problem type</param>
		/// <returns>response value</returns>
		/// ------------------------------------------------------------------------------------
		public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
			VwDelProbType dpt)
		{
			CheckDisposed();

			switch (dpt)
			{
			case VwDelProbType.kdptBsAtStartPara:
			case VwDelProbType.kdptDelAtEndPara:
			case VwDelProbType.kdptNone:
				return VwDelProbResponse.kdprDone;
			case VwDelProbType.kdptBsReadOnly:
			case VwDelProbType.kdptComplexRange:
			case VwDelProbType.kdptDelReadOnly:
			case VwDelProbType.kdptReadOnly:
				return VwDelProbResponse.kdprFail;
			}
			return VwDelProbResponse.kdprAbort;
		}
Ejemplo n.º 8
0
		public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
			VwDelProbType dpt)
		{
			CheckDisposed();
			int cvsli;
			int hvoObj;
			if (!CheckForValidDelete(sel, out cvsli, out hvoObj))
				return VwDelProbResponse.kdprAbort;

			return DeleteObjectFromVector(sel, cvsli, hvoObj);
		}
Ejemplo n.º 9
0
			OnProblemDeletion(IVwSelection _sel, VwDelProbType dpt)
		{
			CheckDisposed();

			// Treat as not implemented and accept the default behavior.
			throw new NotImplementedException();
		}
Ejemplo n.º 10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Merges the paras in table.
		/// </summary>
		/// <param name="helper">The helper.</param>
		/// <param name="dpt">The problem deletion type.</param>
		/// <returns><c>true</c> if we merged the paras, otherwise <c>false</c>.</returns>
		/// ------------------------------------------------------------------------------------
		internal protected bool MergeParasInTable(SelectionHelper helper, VwDelProbType dpt)
		{
			SelLevInfo[] levInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.Top);
			if (levInfo[0].tag != (int)StText.StTextTags.kflidParagraphs)
				return false;

			ILocationTracker tracker = ((ITeView)Control).LocationTracker;
			IScrBook book = new ScrBook(m_cache, tracker.GetBookHvo(
				helper, SelectionHelper.SelLimitType.Anchor));

			SelLevInfo tmpInfo;
			IStText text;
			if (helper.GetLevelInfoForTag((int)ScrBook.ScrBookTags.kflidTitle, out tmpInfo))
				text = book.TitleOA;
			else
			{
				IScrSection section = book.SectionsOS[tracker.GetSectionIndexInBook(
					helper,	SelectionHelper.SelLimitType.Anchor)];

				text = (levInfo[1].tag == (int)ScrSection.ScrSectionTags.kflidHeading ?
					section.HeadingOA :	text = section.ContentOA);
			}

			int iPara = helper.GetLevelInfoForTag((int)StText.StTextTags.kflidParagraphs).ihvo;
			StTxtPara currPara = (StTxtPara)text.ParagraphsOS[iPara];
			ITsStrBldr bldr;

			// Backspace at beginning of paragraph
			if (dpt == VwDelProbType.kdptBsAtStartPara)
			{
				if (iPara <= 0)
				{
					MiscUtils.ErrorBeep();
					return false;
				}

				StTxtPara prevPara = (StTxtPara)text.ParagraphsOS[iPara - 1];
				int prevParaLen = prevPara.Contents.Length;

				// Need to make sure we move the back translations
				AboutToDelete(helper, currPara.Hvo, text.Hvo,
					(int)StText.StTextTags.kflidParagraphs, iPara, false);

				bldr = prevPara.Contents.UnderlyingTsString.GetBldr();
				bldr.ReplaceTsString(prevPara.Contents.Length, prevPara.Contents.Length,
					currPara.Contents.UnderlyingTsString);
				prevPara.Contents.UnderlyingTsString = bldr.GetString();
				text.ParagraphsOS.RemoveAt(iPara);
				helper.SetIch(SelectionHelper.SelLimitType.Top, prevParaLen);
				helper.SetIch(SelectionHelper.SelLimitType.Bottom, prevParaLen);
				levInfo[0].ihvo = iPara - 1;
				helper.SetLevelInfo(SelectionHelper.SelLimitType.Top, levInfo);
				helper.SetLevelInfo(SelectionHelper.SelLimitType.Bottom, levInfo);
				helper.SetSelection(true);
				return true;
			}
			// delete at end of a paragraph
			int cParas = text.ParagraphsOS.Count;
			if (iPara + 1 >= cParas)
				return false; // We don't handle merging across StTexts

			StTxtPara nextPara = (StTxtPara)text.ParagraphsOS[iPara + 1];

			// Need to make sure we move the back translations
			AboutToDelete(helper, nextPara.Hvo, text.Hvo,
				(int)StText.StTextTags.kflidParagraphs, iPara + 1, false);

			bldr = currPara.Contents.UnderlyingTsString.GetBldr();
			bldr.ReplaceTsString(currPara.Contents.Length, currPara.Contents.Length,
				nextPara.Contents.UnderlyingTsString);
			currPara.Contents.UnderlyingTsString = bldr.GetString();
			text.ParagraphsOS.RemoveAt(iPara + 1);
			helper.SetSelection(true);
			return true;
		}
Ejemplo n.º 11
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// The user has attempted to delete something which the system does not inherently
 /// know how to delete. The dpt argument indicates the type of problem.
 /// </summary>
 /// <param name="sel">The selection</param>
 /// <param name="dpt">Problem type</param>
 /// <returns><c>true</c> to abort</returns>
 /// ------------------------------------------------------------------------------------
 VwDelProbResponse IVwRootSite.OnProblemDeletion(IVwSelection sel, VwDelProbType dpt)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// The user has attempted to delete something which the system does not inherently
		/// know how to delete. The dpt argument indicates the type of problem.
		/// </summary>
		/// <param name="sel">The selection</param>
		/// <param name="dpt">Problem type</param>
		/// <returns><c>true</c> to abort</returns>
		/// ------------------------------------------------------------------------------------
		VwDelProbResponse IVwRootSite.OnProblemDeletion(IVwSelection sel, VwDelProbType dpt)
		{
			throw new NotImplementedException();
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Calls <c>m_draftView.OnProblemDeletion</c> after first setting the flag to ensure
		/// that any new selection is just saved in a variable and not actually made (since
		/// the UOW covers the entire test fixture and therefore the needed PropChanged calls
		/// are not issued).
		/// </summary>
		/// <param name="sel">The (range) selection on which the delete is called.</param>
		/// <param name="type">The type of selection that makes this deletion problematic</param>
		/// ------------------------------------------------------------------------------------
		private void CallOnProblemDeletion(IVwSelection sel, VwDelProbType type)
		{
			((TestTeEditingHelper)m_draftView.EditingHelper).m_DeferSelectionUntilEndOfUOW = true;
			m_selInitial = sel;
			// Now do the real thing
			m_draftView.OnProblemDeletion(sel, type);
		}
Ejemplo n.º 14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// The user has attempted to delete something which the system does not inherently
		/// know how to delete. The dpt argument indicates the type of problem.
		/// </summary>
		/// <param name="sel">The selection</param>
		/// <param name="dpt">Problem type</param>
		/// <returns><c>true</c> to abort</returns>
		/// ------------------------------------------------------------------------------------
		public virtual VwDelProbResponse OnProblemDeletion(IVwSelection sel,
			VwDelProbType dpt)
		{
			CheckDisposed();
			throw new NotImplementedException();
			// the following seems like a better action
			// return VwDelProbResponse.kdprAbort;
		}
Ejemplo n.º 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// The user has attempted to delete something which the system does not inherently
		/// know how to delete. The dpt argument indicates the type of problem.
		/// </summary>
		/// <param name="sel">The selection</param>
		/// <param name="dpt">Problem type</param>
		/// <returns><c>true</c> to abort</returns>
		/// ------------------------------------------------------------------------------------
		public virtual VwDelProbResponse OnProblemDeletion(IVwSelection sel,
			VwDelProbType dpt)
		{
			CheckDisposed();
			return VwDelProbResponse.kdprFail; // give up quietly.
			// Review team (JohnT): a previous version threw NotImplementedException. This seems
			// overly drastic.
		}
		/// <summary>
		/// The user has attempted to delete something which the system does not inherently
		/// know how to delete.  If the problem is a "complex range", then try to delete one
		/// object from the vector displayed in the entry sequence.
		/// </summary>
		public override VwDelProbResponse OnProblemDeletion(IVwSelection sel, VwDelProbType dpt)
		{
			if (dpt == VwDelProbType.kdptComplexRange)
			{
				var helper = SelectionHelper.GetSelectionInfo(sel, this);
				var clev = helper.NumberOfLevels;
				var rginfo = helper.LevelInfo;
				var info = rginfo[clev - 1];
				ICmObject cmo;
				if (info.tag == m_rootFlid &&
					m_fdoCache.ServiceLocator.ObjectRepository.TryGetObject(info.hvo, out cmo))
				{
					var sda = m_fdoCache.DomainDataByFlid as ISilDataAccessManaged;
					Debug.Assert(sda != null);
					var rghvos = sda.VecProp(m_rootObj.Hvo, m_rootFlid);
					var ihvo = -1;
					for (var i = 0; i < rghvos.Length; ++i)
					{
						if (rghvos[i] == cmo.Hvo)
						{
							ihvo = i;
							break;
						}
					}
					if (ihvo >= 0)
					{
						var startHeight = m_rootb.Height;
						if (Cache.MetaDataCacheAccessor.get_IsVirtual(m_rootFlid))
						{
							var obj = m_fdoCache.ServiceLocator.GetObject(rghvos[ihvo]);
							ILexEntryRef ler = null;
							if (obj is ILexEntry)
							{
								var complex = (ILexEntry)obj;
								// the selected object in the list is a complex entry which has this as one of
								// its components.  We want to remove this from its components.
								foreach (var item in complex.EntryRefsOS)
								{
									switch (item.RefType)
									{
										case LexEntryRefTags.krtComplexForm:
										case LexEntryRefTags.krtVariant:
											ler = item;
											break;
										default:
											throw new Exception("Unexpected LexEntryRef type in EntrySequenceVectorReferenceView.OnProblemDeletion");
									}
								}
							}
							else if (obj is ILexEntryRef)
							{
								ler = (ILexEntryRef) obj;
							}
							else
							{
								return VwDelProbResponse.kdprAbort; // we don't know how to delete it.
							}
							var fieldName = m_fdoCache.MetaDataCacheAccessor.GetFieldName(m_rootFlid);
							if (fieldName == "Subentries")
							{
								ler.PrimaryLexemesRS.Remove(m_rootObj);
							}
							else if (fieldName == "VisibleComplexFormEntries" || fieldName == "VisibleComplexFormBackRefs")
							{
								ler.ShowComplexFormsInRS.Remove(m_rootObj);
							}
							else if (fieldName == "VariantFormEntries")
							{
								ler.ComponentLexemesRS.Remove(m_rootObj);
							}
						}
						else
						{
							sda.Replace(m_rootObj.Hvo, m_rootFlid, ihvo, ihvo + 1, new int[0], 0);
						}
						if (m_rootb != null)
						{
							CheckViewSizeChanged(startHeight, m_rootb.Height);
							// Redisplay (?) the vector property.
							m_rootb.SetRootObject(m_rootObj.Hvo, m_VectorReferenceVc, kfragTargetVector,
								m_rootb.Stylesheet);
						}
						return VwDelProbResponse.kdprDone;
					}
				}
			}
			return base.OnProblemDeletion(sel, dpt);
		}
Ejemplo n.º 17
0
		/// <summary>
		/// Handle a problem deleting some selection in the sandbox. So far, the only cases we
		/// handle are backspace and delete merging morphemes.
		/// Enhance JohnT: could also handle deleting a range that merges morphemes.
		/// </summary>
		/// <param name="sel"></param>
		/// <param name="dpt"></param>
		/// <returns></returns>
		public override VwDelProbResponse OnProblemDeletion(IVwSelection sel, VwDelProbType dpt)
		{
			CheckDisposed();

			ITsString tss = null;
			bool fAssocPrev = false;
			int ichSel = -1;
			int hvoObj = 0;
			int tag = 0;
			int ws;
			sel.TextSelInfo(false, out tss, out ichSel, out fAssocPrev, out hvoObj, out tag, out ws);
			if (!m_editMonitor.IsPropMorphBreak(hvoObj, tag, ws))
				return VwDelProbResponse.kdprFail;
			switch (dpt)
			{
				case VwDelProbType.kdptBsAtStartPara:
				case VwDelProbType.kdptBsReadOnly:
					return m_editMonitor.HandleBackspace() ?
						VwDelProbResponse.kdprDone : VwDelProbResponse.kdprFail;
				case VwDelProbType.kdptDelAtEndPara:
				case VwDelProbType.kdptDelReadOnly:
					return m_editMonitor.HandleDelete() ?
						VwDelProbResponse.kdprDone : VwDelProbResponse.kdprFail;
				default:
					return VwDelProbResponse.kdprFail;
			}
		}
Ejemplo n.º 18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Merges the paras in table.
		/// </summary>
		/// <param name="helper">The helper.</param>
		/// <param name="dpt">The problem deletion type.</param>
		/// <returns><c>true</c> if we merged the paras, otherwise <c>false</c>.</returns>
		/// ------------------------------------------------------------------------------------
		protected internal bool MergeParasInTable(SelectionHelper helper, VwDelProbType dpt)
		{
			SelLevInfo[] levInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.Top);
			if (levInfo[0].tag != StTextTags.kflidParagraphs)
				return false;
			IStText text;
			int iPara;
			int tag;
			IStTxtPara currPara = GetPara(helper, out text, out iPara, out tag);

			// Backspace at beginning of paragraph
			ITsStrBldr bldr;
			if (dpt == VwDelProbType.kdptBsAtStartPara)
			{
				if (iPara <= 0)
				{
					MiscUtils.ErrorBeep();
					return false;
				}

				IStTxtPara prevPara = text[iPara - 1];
				int prevParaLen = prevPara.Contents.Length;

				prevPara.MergeParaWithNext();

				helper.SetIch(SelectionHelper.SelLimitType.Top, prevParaLen);
				helper.SetIch(SelectionHelper.SelLimitType.Bottom, prevParaLen);
				levInfo[0].ihvo = iPara - 1;
				helper.SetLevelInfo(SelectionHelper.SelLimitType.Top, levInfo);
				helper.SetLevelInfo(SelectionHelper.SelLimitType.Bottom, levInfo);
				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(!helper.IsRange,
						"Currently, a selection made during a unit of work can only be an insertion point.");
					helper.SetIPAfterUOW(EditedRootBox.Site);
				}
				else
				{
					helper.SetSelection(true);
				}
				return true;
			}
			// delete at end of a paragraph
			int cParas = text.ParagraphsOS.Count;
			if (iPara + 1 >= cParas)
				return false; // We don't handle merging across StTexts

			currPara.MergeParaWithNext();

			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(!helper.IsRange,
					"Currently, a selection made during a unit of work can only be an insertion point.");
				helper.SetIPAfterUOW(EditedRootBox.Site);
			}
			else
			{
				helper.SetSelection(true);
			}
			return true;
		}
Ejemplo n.º 19
0
        /// <summary>
        /// The user has attempted to delete something which the system does not inherently
        /// know how to delete.  If the problem is a "complex range", then try to delete one
        /// object from the vector displayed in the entry sequence.
        /// </summary>
        public override VwDelProbResponse OnProblemDeletion(IVwSelection sel, VwDelProbType dpt)
        {
            if (dpt == VwDelProbType.kdptComplexRange)
            {
                var       helper = SelectionHelper.GetSelectionInfo(sel, this);
                var       clev   = helper.NumberOfLevels;
                var       rginfo = helper.LevelInfo;
                var       info   = rginfo[clev - 1];
                ICmObject cmo;
                if (info.tag == m_rootFlid &&
                    m_cache.ServiceLocator.ObjectRepository.TryGetObject(info.hvo, out cmo))
                {
                    var sda = m_cache.DomainDataByFlid as ISilDataAccessManaged;
                    Debug.Assert(sda != null);
                    var rghvos = sda.VecProp(m_rootObj.Hvo, m_rootFlid);
                    var ihvo   = -1;
                    for (var i = 0; i < rghvos.Length; ++i)
                    {
                        if (rghvos[i] == cmo.Hvo)
                        {
                            ihvo = i;
                            break;
                        }
                    }
                    if (ihvo >= 0)
                    {
                        var startHeight = m_rootb.Height;
                        if (Cache.MetaDataCacheAccessor.get_IsVirtual(m_rootFlid))
                        {
                            var          obj = m_cache.ServiceLocator.GetObject(rghvos[ihvo]);
                            ILexEntryRef ler = null;
                            if (obj is ILexEntry)
                            {
                                var complex = (ILexEntry)obj;
                                // the selected object in the list is a complex entry which has this as one of
                                // its components.  We want to remove this from its components.
                                foreach (var item in complex.EntryRefsOS)
                                {
                                    switch (item.RefType)
                                    {
                                    case LexEntryRefTags.krtComplexForm:
                                    case LexEntryRefTags.krtVariant:
                                        ler = item;
                                        break;

                                    default:
                                        throw new Exception("Unexpected LexEntryRef type in EntrySequenceVectorReferenceView.OnProblemDeletion");
                                    }
                                }
                            }
                            else if (obj is ILexEntryRef)
                            {
                                ler = (ILexEntryRef)obj;
                            }
                            else
                            {
                                return(VwDelProbResponse.kdprAbort);                                // we don't know how to delete it.
                            }
                            var fieldName = m_cache.MetaDataCacheAccessor.GetFieldName(m_rootFlid);
                            if (fieldName == "Subentries")
                            {
                                ler.PrimaryLexemesRS.Remove(m_rootObj);
                            }
                            else if (fieldName == "VisibleComplexFormEntries" || fieldName == "VisibleComplexFormBackRefs")
                            {
                                ler.ShowComplexFormsInRS.Remove(m_rootObj);
                            }
                            else if (fieldName == "VariantFormEntries")
                            {
                                ler.ComponentLexemesRS.Remove(m_rootObj);
                            }
                        }
                        else
                        {
                            sda.Replace(m_rootObj.Hvo, m_rootFlid, ihvo, ihvo + 1, new int[0], 0);
                        }
                        if (m_rootb != null)
                        {
                            CheckViewSizeChanged(startHeight, m_rootb.Height);
                            // Redisplay (?) the vector property.
                            m_rootb.SetRootObject(m_rootObj.Hvo, m_VectorReferenceVc, kfragTargetVector,
                                                  m_rootb.Stylesheet);
                        }
                        return(VwDelProbResponse.kdprDone);
                    }
                }
            }
            return(base.OnProblemDeletion(sel, dpt));
        }
Ejemplo n.º 20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle a problem deletion - a complex selection crossing sections or other
		/// difficult cases such as BS/DEL at boundaries.
		/// </summary>
		/// <param name="sel"></param>
		/// <param name="dpt"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public VwDelProbResponse OnProblemDeletion(IVwSelection sel,
			VwDelProbType dpt)
		{
			CheckDisposed();

			// Problem deletions are not permitted in a back translation text.
			if (IsBackTranslation)
			{
				MiscUtils.ErrorBeep();
				return VwDelProbResponse.kdprAbort;
			}

			SelectionHelper helper = SelectionHelper.GetSelectionInfo(sel,
				Callbacks.EditedRootBox.Site);

			if (helper == null)
			{
				MiscUtils.ErrorBeep();
				throw new NotImplementedException();
			}

			// There should only be one scripture object as the root of the view.
			// If this changes, enhance this method to fail if they are not equal.
			Debug.Assert(helper.GetIhvoRoot(SelectionHelper.SelLimitType.Top) == 0);
			Debug.Assert(helper.GetIhvoRoot(SelectionHelper.SelLimitType.Bottom) == 0);

			// Handle a BS/DEL at the boundary of a paragraph
			if (dpt == VwDelProbType.kdptBsAtStartPara ||
				dpt == VwDelProbType.kdptDelAtEndPara)
			{
				using (new WaitCursor(Control))
				{
					if (HandleBsOrDelAtTextBoundary(helper, dpt))
						return VwDelProbResponse.kdprDone;
				}
			}

				// handle a complex selection range where the deletion will require restructuring
				// paragraphs or sections.
			else if (dpt == VwDelProbType.kdptComplexRange)
			{
				using (new WaitCursor(Control))
				{
					if (HandleComplexDeletion(helper))
						return VwDelProbResponse.kdprDone;
					else
					{
						// Don't want default behavior for complex deletions since it
						// only will delete a single paragraph and this is probably worse
						// than doing nothing.
						MiscUtils.ErrorBeep();
						return VwDelProbResponse.kdprAbort;
					}
				}
			}
			// If it's not a case we know how to deal with, treat as not implemented and accept
			// the default behavior.

			MiscUtils.ErrorBeep();
			throw new NotImplementedException();
		}
Ejemplo n.º 21
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle a problem deletion - a complex selection crossing sections or other
		/// difficult cases such as BS/DEL at boundaries.
		/// </summary>
		/// <param name="sel"></param>
		/// <param name="dpt"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public override VwDelProbResponse OnProblemDeletion(IVwSelection sel,
			VwDelProbType dpt)
		{
			CheckDisposed();

			return TeEditingHelper.OnProblemDeletion(sel, dpt);
		}
Ejemplo n.º 22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Try to do something about an IP selection deletion that is at the start or end of an
		/// StText. If successful return true, otherwise false.
		/// </summary>
		/// <param name="helper"></param>
		/// <param name="dpt"></param>
		/// <returns><c>true</c> if we successfully handled the deletion.</returns>
		/// ------------------------------------------------------------------------------------
		internal bool HandleBsOrDelAtTextBoundary(SelectionHelper helper, VwDelProbType dpt)
		{
			CheckDisposed();

			SelLevInfo[] levInfo = helper.GetLevelInfo(SelectionHelper.SelLimitType.Anchor);

			ILocationTracker tracker = ((ITeView)Control).LocationTracker;
			// bail out if we are not in a paragraph within a scripture section
			if (levInfo.Length !=
				tracker.GetLevelCount((int)ScrSection.ScrSectionTags.kflidContent) ||
				tracker.GetSectionIndexInView(helper, SelectionHelper.SelLimitType.Anchor) < 0 ||
				levInfo[0].tag != (int)StText.StTextTags.kflidParagraphs)
			{
				// Assume we are in a book title
				SelLevInfo dummyInfo;
				if (helper.GetLevelInfoForTag((int)ScrBook.ScrBookTags.kflidTitle, out dummyInfo))
					return MergeParasInTable(helper, dpt);
				return false;
			}

			// Level 1 will have tags showing which field of section is selected
			int iLevelSection = helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidHeading);
			if (iLevelSection >= 0)
			{
				if (levInfo[0].ihvo == 0 && dpt == VwDelProbType.kdptBsAtStartPara)
				{
					// first paragraph of section head
					return HandleBackspaceAfterEmptyContentParagraph(helper);
				}
				else if (levInfo[0].ihvo == 0 && helper.IchAnchor == 0)
				{
					// Delete was pressed in an empty section head - try to combine with previous
					// return DeleteSectionHead(helper, false, false);
					if (dpt == VwDelProbType.kdptBsAtStartPara)
						return HandleBackspaceAfterEmptySectionHeadParagraph(helper);
					return HandleDeleteBeforeEmptySectionHeadParagraph(helper);
				}
				// NOTE: we check the vector size for the parent of the paragraph (levInfo[1].hvo)
				// but with our own tag (levInfo[0].tag)!
				else if (levInfo[0].ihvo == m_cache.GetVectorSize(levInfo[iLevelSection].hvo,
					levInfo[0].tag) - 1
					&& dpt == VwDelProbType.kdptDelAtEndPara)
				{
					// last paragraph of section head
					return HandleDeleteBeforeEmptySectionContentParagraph(helper);
				}
				else
				{
					// other problem deletion: e.g. delete in BT side-by-side view. Because
					// we're displaying the paragraphs in a table with two columns, the views
					// code can't handle that. We have to merge the two paragraphs manually.
					return MergeParasInTable(helper, dpt);
				}
			}
			else if (helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidContent) >= 0)
			{
				iLevelSection = helper.GetLevelForTag((int)ScrSection.ScrSectionTags.kflidContent);
				if (levInfo[0].ihvo == 0 && dpt == VwDelProbType.kdptBsAtStartPara)
				{
					// first paragraph of section
					return HandleBackspaceAfterEmptySectionHeadParagraph(helper);
				}
				else if (levInfo[0].ihvo == 0 && helper.IchAnchor == 0)
				{
					// Delete was pressed in an empty section content - try to combine with previous
					if (dpt == VwDelProbType.kdptBsAtStartPara)
						return HandleBackspaceAfterEmptyContentParagraph(helper);
					return HandleDeleteBeforeEmptySectionContentParagraph(helper);
				}
				// NOTE: we check the vector size for the parent of the paragraph (levInfo[1].hvo)
				// but with our own tag (levInfo[0].tag)!
				else if (levInfo[0].ihvo == m_cache.GetVectorSize(levInfo[iLevelSection].hvo,
					levInfo[0].tag) - 1 && dpt == VwDelProbType.kdptDelAtEndPara)
				{
					// last paragraph of section
					return HandleDeleteBeforeEmptySectionHeadParagraph(helper);
				}
				else
				{
					// other problem deletion: e.g. delete in BT side-by-side view. Because
					// we're displaying the paragraphs in a table with two columns, the views
					// code can't handle that. We have to merge the two paragraphs manually.
					return MergeParasInTable(helper, dpt);
				}
			}
			return false;
		}