Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Set both book and section. Don't make a selection; typically the caller will proceed
        /// to do that.
        /// </summary>
        /// <param name="selHelper">The selection helper.</param>
        /// <param name="selLimitType">Which end of the selection</param>
        /// <param name="iBook">The index of the book (in the book filter).</param>
        /// <param name="iSection">The index of the section (relative to
        /// <paramref name="iBook"/>), or -1 for a selection that is not in a section (e.g.
        /// title).</param>
        /// <remarks>This method should change only the book and section levels of the
        /// selection, but not any other level.</remarks>
        /// ------------------------------------------------------------------------------------
        public virtual void SetBookAndSection(SelectionHelper selHelper,
                                              SelectionHelper.SelLimitType selLimitType, int iBook, int iSection)
        {
            if (selHelper == null || iBook < 0)
            {
                return;
            }

            int nLevels = selHelper.GetNumberOfLevels(selLimitType);

            if (nLevels == 0)
            {
                Debug.Fail("This should not happen!!!");
                return;
            }

            selHelper.GetLevelInfo(selLimitType)[nLevels - 1].tag  = BookTag;
            selHelper.GetLevelInfo(selLimitType)[nLevels - 1].ihvo = iBook;

            if (iSection >= 0 && nLevels >= 2)
            {
                selHelper.GetLevelInfo(selLimitType)[nLevels - 2].tag =
                    (int)ScrBook.ScrBookTags.kflidSections;
                selHelper.GetLevelInfo(selLimitType)[nLevels - 2].ihvo = iSection;
            }
        }
Esempio n. 2
0
        protected override int GetCell(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (sel == null)
            {
                return(-1);
            }

            int tag = sel.GetTextPropId(limit);

            if (tag == AffixRuleFormulaVc.ktagLeftEmpty ||
                tag == AffixRuleFormulaVc.ktagRightEmpty ||
                tag == MoAffixProcessTags.kflidOutput)
            {
                return(tag);
            }

            foreach (SelLevInfo level in sel.GetLevelInfo(limit))
            {
                if (level.tag == MoAffixProcessTags.kflidOutput)
                {
                    return(level.tag);
                }
                if (level.tag == MoAffixProcessTags.kflidInput)
                {
                    return(level.hvo);
                }
            }

            return(-1);
        }
        protected override int GetCell(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            int tag = sel.GetTextPropId(limit);

            switch (tag)
            {
            case MetaRuleFormulaVc.ktagLeftEnv:
                return(PhMetathesisRule.kidxLeftEnv);

            case MetaRuleFormulaVc.ktagLeftSwitch:
                return(PhMetathesisRule.kidxLeftSwitch);

            case MetaRuleFormulaVc.ktagRightSwitch:
                return(PhMetathesisRule.kidxRightSwitch);

            case MetaRuleFormulaVc.ktagRightEnv:
                return(PhMetathesisRule.kidxRightEnv);
            }

            int hvo = GetItemHvo(sel, limit);

            if (hvo == 0)
            {
                return(-1);
            }

            return(Rule.GetStrucChangeIndex(hvo));
        }
Esempio n. 4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Set both book and section. Don't make a selection; typically the caller will proceed
 /// to do that.
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <param name="iBook">The index of the book (in the book filter).</param>
 /// <param name="iSection">The index of the section (relative to
 /// <paramref name="iBook"/>), or -1 for a selection that is not in a section (e.g.
 /// title).</param>
 /// <remarks>This method should change only the book and section levels of the
 /// selection, but not any other level.</remarks>
 /// ------------------------------------------------------------------------------------
 public override void SetBookAndSection(SelectionHelper selHelper,
                                        SelectionHelper.SelLimitType selLimitType, int iBook, int iSection)
 {
     m_vDraft.m_bookIndex    = iBook;
     m_vDraft.m_sectionIndex = iSection;
     m_vDraft.MakeRootObject();
 }
        protected override int GetCell(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            int tag = sel.GetTextPropId(limit);

            switch (tag)
            {
            case MetaRuleFormulaVc.ktagLeftEnv:
                return(PhMetathesisRuleTags.kidxLeftEnv);

            case MetaRuleFormulaVc.ktagLeftSwitch:
                return(PhMetathesisRuleTags.kidxLeftSwitch);

            case MetaRuleFormulaVc.ktagRightSwitch:
                return(PhMetathesisRuleTags.kidxRightSwitch);

            case MetaRuleFormulaVc.ktagRightEnv:
                return(PhMetathesisRuleTags.kidxRightEnv);
            }

            var obj = GetItem(sel, limit);

            if (obj == null)
            {
                return(-1);
            }

            return(Rule.GetStrucChangeIndex(obj as IPhSimpleContext));
        }
Esempio n. 6
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the HVO of the current book, or -1 if there is no current book (e.g. no
 /// selection or empty view).
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>The book hvo.</returns>
 /// ------------------------------------------------------------------------------------
 public override int GetBookHvo(SelectionHelper selHelper, SelectionHelper.SelLimitType selLimitType)
 {
     if (BookHvo == -1)
     {
         return(base.GetBookHvo(selHelper, selLimitType));
     }
     return(BookHvo);
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the HVO of the current book, or -1 if there is no current book (e.g. no
 /// selection or empty view).
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>The book hvo.</returns>
 /// ------------------------------------------------------------------------------------
 public override IScrBook GetBook(SelectionHelper selHelper, SelectionHelper.SelLimitType selLimitType)
 {
     if (BookHvo == -1)
     {
         return(base.GetBook(selHelper, selLimitType));
     }
     return(Cache.ServiceLocator.GetInstance <IScrBookRepository>().GetObject(BookHvo));
 }
Esempio n. 8
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Get the name of the current book in the corresponding draft view.
        /// </summary>
        /// <param name="selLimitType">Specify Top or Bottom</param>
        /// -----------------------------------------------------------------------------------
        public override string CurrentBook(SelectionHelper.SelLimitType selLimitType)
        {
            CheckDisposed();

            if (m_draftView != null)
            {
                return(m_draftViewEditingHelper.CurrentBook(selLimitType));
            }
            return(string.Empty);
        }
        protected override int GetItemHvo(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (Rule.StrucDescOS.Count == 0 || sel.GetNumberOfLevels(limit) == 0)
            {
                return(0);
            }

            SelLevInfo[] levels = sel.GetLevelInfo(limit);
            return(levels[levels.Length - 1].hvo);
        }
        protected override ICmObject GetItem(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (Rule.StrucDescOS.Count == 0 || sel.GetNumberOfLevels(limit) == 0)
            {
                return(null);
            }

            var levels = sel.GetLevelInfo(limit);

            return(m_cache.ServiceLocator.GetObject(levels[levels.Length - 1].hvo));
        }
Esempio n. 11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the HVO of the current section, or -1 if we're not in a section (e.g. the IP is
        /// in a title).
        /// </summary>
        /// <param name="selHelper">The selection helper.</param>
        /// <param name="selLimitType">Which end of the selection</param>
        /// <returns>The section hvo.</returns>
        /// ------------------------------------------------------------------------------------
        public virtual int GetSectionHvo(SelectionHelper selHelper, SelectionHelper.SelLimitType selLimitType)
        {
            if (selHelper == null)
            {
                return(-1);
            }

            SelLevInfo levInfo;

            if (selHelper.GetLevelInfoForTag((int)ScrBook.ScrBookTags.kflidSections,
                                             selLimitType, out levInfo))
            {
                return(levInfo.hvo);
            }
            return(-1);
        }
Esempio n. 12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the HVO of the current book, or -1 if there is no current book (e.g. no
        /// selection or empty view).
        /// </summary>
        /// <param name="selHelper">The selection helper.</param>
        /// <param name="selLimitType">Which end of the selection</param>
        /// <returns>The book hvo.</returns>
        /// ------------------------------------------------------------------------------------
        public virtual int GetBookHvo(SelectionHelper selHelper,
                                      SelectionHelper.SelLimitType selLimitType)
        {
            if (selHelper == null)
            {
                return(-1);
            }

            SelLevInfo levInfo;

            if (selHelper.GetLevelInfoForTag(BookTag, selLimitType, out levInfo))
            {
                return(levInfo.hvo);
            }
            return(-1);
        }
Esempio n. 13
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the current book, or null if there is no current book (e.g. no selection or
        /// empty view).
        /// </summary>
        /// <param name="selHelper">The selection helper.</param>
        /// <param name="selLimitType">Which end of the selection</param>
        /// <returns>The book, or null if there isn't a current book.</returns>
        /// ------------------------------------------------------------------------------------
        public virtual IScrBook GetBook(SelectionHelper selHelper,
                                        SelectionHelper.SelLimitType selLimitType)
        {
            if (selHelper == null)
            {
                return(null);
            }

            SelLevInfo levInfo;

            if (selHelper.GetLevelInfoForTag(BookTag, selLimitType, out levInfo))
            {
                return(m_cache.ServiceLocator.GetInstance <IScrBookRepository>().GetObject(levInfo.hvo));
            }
            return(null);
        }
Esempio n. 14
0
        private ComplexConcPatternNode GetNode(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (sel == null || m_patternModel.Root.IsLeaf)
            {
                return(null);
            }

            SelLevInfo[] levels = sel.GetLevelInfo(limit);
            if (levels.Length == 0)
            {
                return(null);
            }

            SelLevInfo level = levels.First(l => l.tag == ComplexConcPatternSda.ktagChildren);

            return(m_patternModel.GetNode(level.hvo));
        }
Esempio n. 15
0
            /// ------------------------------------------------------------------------------------
            /// <summary>
            /// Set both book and section. Don't make a selection; typically the caller will proceed
            /// to do that.
            /// </summary>
            /// <param name="selHelper">The selection helper.</param>
            /// <param name="selLimitType">Which end of the selection</param>
            /// <param name="iBook">The index of the book (in the book filter).</param>
            /// <param name="iSection">The index of the section (relative to
            /// <paramref name="iBook"/>), or -1 for a selection that is not in a section (e.g.
            /// title).</param>
            /// <remarks>This method should change only the book and section levels of the
            /// selection, but not any other level.</remarks>
            /// ------------------------------------------------------------------------------------
            public override void SetBookAndSection(SelectionHelper selHelper,
                                                   SelectionHelper.SelLimitType selLimitType, int iBook, int iSection)
            {
                if (selHelper == null)
                {
                    return;
                }

                // we can only deal with one book
                if (iBook != GetBookIndex(null, selLimitType) || iSection < 0)
                {
                    return;
                }

                int nLevels = selHelper.GetNumberOfLevels(selLimitType);

                selHelper.GetLevelInfo(selLimitType)[nLevels - 1].tag  = ScrBookTags.kflidSections;
                selHelper.GetLevelInfo(selLimitType)[nLevels - 1].ihvo = iSection;
            }
Esempio n. 16
0
        protected override ICmObject GetCmObject(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (sel == null)
            {
                return(null);
            }

            foreach (SelLevInfo level in sel.GetLevelInfo(limit))
            {
                if (level.tag == MoAffixProcessTags.kflidInput ||
                    level.tag == PhSequenceContextTags.kflidMembers ||
                    level.tag == MoAffixProcessTags.kflidOutput)
                {
                    return(m_cache.ServiceLocator.GetObject(level.hvo));
                }
            }

            return(null);
        }
Esempio n. 17
0
        protected override int GetCell(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (sel == null)
            {
                return(-1);
            }

            foreach (SelLevInfo level in sel.GetLevelInfo(limit))
            {
                if (IsCellFlid(level.tag))
                {
                    return(level.tag);
                }
            }

            if (IsCellFlid(sel.GetTextPropId(limit)))
            {
                return(sel.GetTextPropId(limit));
            }
            return(-1);
        }
Esempio n. 18
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);
            }
        }
Esempio n. 19
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the current section, or null if we're not in a section (e.g. the IP is in a
        /// title).
        /// </summary>
        /// <param name="selHelper">The selection helper.</param>
        /// <param name="selLimitType">Which end of the selection</param>
        /// <returns>The section or null if we're not in a section.</returns>
        /// ------------------------------------------------------------------------------------
        public virtual IScrSection GetSection(SelectionHelper selHelper,
                                              SelectionHelper.SelLimitType selLimitType)
        {
            if (selHelper == null)
            {
                return(null);
            }

            SelLevInfo levInfo;

            if (selHelper.GetLevelInfoForTag(ScrBookTags.kflidSections,
                                             selLimitType, out levInfo))
            {
                IScrSection section;
                if (m_cache.ServiceLocator.GetInstance <IScrSectionRepository>().TryGetObject(levInfo.hvo, out section))
                {
                    return(section);
                }
            }
            return(null);
        }
Esempio n. 20
0
        protected override ICmObject GetCmObject(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (sel == null)
            {
                return(null);
            }

            int cellId = GetCell(sel);

            if (cellId < 0)
            {
                return(null);
            }

            foreach (SelLevInfo level in sel.GetLevelInfo(limit))
            {
                if (IsCellFlid(level.tag) || level.tag == PhSequenceContextTags.kflidMembers)
                {
                    return(m_cache.ServiceLocator.GetObject(level.hvo));
                }
            }

            return(null);
        }
Esempio n. 21
0
        protected override int GetItemHvo(SelectionHelper sel, SelectionHelper.SelLimitType limit)
        {
            if (sel == null)
            {
                return(0);
            }

            int cellId = GetCell(sel);

            if (cellId < 0)
            {
                return(0);
            }

            foreach (SelLevInfo level in sel.GetLevelInfo(limit))
            {
                if (IsCellFlid(level.tag) || level.tag == (int)PhSequenceContext.PhSequenceContextTags.kflidMembers)
                {
                    return(level.hvo);
                }
            }

            return(0);
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Get the index of the section (relative to RootBox), or -1 if we're not in a section
 /// (e.g. the IP is in a title).
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>
 /// Index of the section, or -1 if we're not in a section.
 /// </returns>
 /// <remarks>The returned value is suitable for making a selection.</remarks>
 /// ------------------------------------------------------------------------------------
 public int GetSectionIndexInView(SelectionHelper selHelper,
                                  SelectionHelper.SelLimitType selLimitType)
 {
     return(m_locationTracker.GetSectionIndexInView(selHelper, selLimitType));
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Get the index of the current book (relative to RootBox), or -1 if there is no
 /// current book (e.g. no selection or empty view).
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>
 /// Index of the current book, or -1 if there is no current book.
 /// </returns>
 /// <remarks>The returned value is suitable for making a selection.</remarks>
 /// ------------------------------------------------------------------------------------
 public int GetBookIndex(SelectionHelper selHelper,
                         SelectionHelper.SelLimitType selLimitType)
 {
     return(m_locationTracker.GetBookIndex(selHelper, selLimitType));
 }
Esempio n. 24
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Get the index of the section (relative to RootBox), or -1 if we're not in a section
 /// (e.g. the IP is in a title).
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>
 /// Index of the section, or -1 if we're not in a section.
 /// </returns>
 /// <remarks>The returned value is suitable for making a selection.</remarks>
 /// ------------------------------------------------------------------------------------
 public override int GetSectionIndexInView(SelectionHelper selHelper,
                                           SelectionHelper.SelLimitType selLimitType)
 {
     return(0);                // always 0
 }
Esempio n. 25
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the index of the section relative to the book, or -1 if we're not in a section.
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>The section index in book.</returns>
 /// ------------------------------------------------------------------------------------
 public override int GetSectionIndexInBook(SelectionHelper selHelper,
                                           SelectionHelper.SelLimitType selLimitType)
 {
     return(m_vDraft.m_sectionIndex);
 }
Esempio n. 26
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the current section, or null if we're not in a section (e.g. the IP is
 /// in a title).
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>The section.</returns>
 /// ------------------------------------------------------------------------------------
 public override IScrSection GetSection(SelectionHelper selHelper,
                                        SelectionHelper.SelLimitType selLimitType)
 {
     return(m_vDraft.BookFilter.GetBook(m_vDraft.m_bookIndex).SectionsOS[m_vDraft.m_sectionIndex]);
 }
Esempio n. 27
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the current book, or null if there is no current book (e.g. no
 /// selection or empty view).
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>The book.</returns>
 /// ------------------------------------------------------------------------------------
 public override IScrBook GetBook(SelectionHelper selHelper,
                                  SelectionHelper.SelLimitType selLimitType)
 {
     return(m_vDraft.BookFilter.GetBook(m_vDraft.m_bookIndex));
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Set both book and section. Don't make a selection; typically the caller will proceed
 /// to do that.
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <param name="iBook">The index of the book (in the book filter).</param>
 /// <param name="iSection">The index of the section (relative to
 /// <paramref name="iBook"/>), or -1 for a selection that is not in a section (e.g.
 /// title).</param>
 /// <remarks>This method should change only the book and section levels of the
 /// selection, but not any other level.</remarks>
 /// ------------------------------------------------------------------------------------
 public void SetBookAndSection(SelectionHelper selHelper,
                               SelectionHelper.SelLimitType selLimitType, int iBook, int iSection)
 {
     m_locationTracker.SetBookAndSection(selHelper, selLimitType, iBook, iSection);
 }
Esempio n. 29
0
        /// <summary>
        /// Creates a selection IP for the specified limit.
        /// </summary>
        /// <param name="sel">The selection.</param>
        /// <param name="limit">The limit.</param>
        /// <param name="vwSel">The new selection.</param>
        /// <param name="curHvo">The current hvo.</param>
        /// <param name="curIch">The current ich.</param>
        /// <param name="curTag">The current tag.</param>
        /// <returns><c>true</c> if we want to create a range selection, otherwise <c>false</c></returns>
        private bool GetSelectionInfo(SelectionHelper sel, SelectionHelper.SelLimitType limit, out IVwSelection vwSel,
                                      out int curHvo, out int curIch, out int curTag)
        {
            vwSel  = null;
            curHvo = 0;
            curIch = -1;
            curTag = -1;

            object obj = m_patternControl.GetItem(sel, limit);

            if (obj == null)
            {
                return(false);
            }

            ITsString curTss;
            int       ws;
            bool      prev;

            sel.Selection.TextSelInfo(limit == SelectionHelper.SelLimitType.End, out curTss, out curIch, out prev, out curHvo, out curTag, out ws);

            object ctxt  = m_patternControl.GetContext(sel);
            int    index = m_patternControl.GetItemContextIndex(ctxt, obj);

            if (!sel.IsRange)
            {
                // if the current selection is an IP, check if it is in one of the off-limits areas, and move the IP
                if (curIch == 0 && curTag == PatternVcBase.ktagLeftNonBoundary)
                {
                    // the cursor is at a non-selectable left edge of an item, so
                    // move to the selectable left edge
                    SelectLeftBoundary(ctxt, index, true);
                    return(false);
                }
                if (curIch == curTss.Length && curTag == PatternVcBase.ktagLeftNonBoundary)
                {
                    // the cursor has been moved to the left from the left boundary, so move the
                    // cursor to the previous item in the cell or the previous cell
                    if (index > 0)
                    {
                        SelectAt(ctxt, index - 1, false, true, true);
                    }
                    else
                    {
                        object prevCtxt = m_patternControl.GetPrevContext(ctxt);
                        if (prevCtxt != null)
                        {
                            SelectCell(prevCtxt, false, true);
                        }
                        else
                        {
                            SelectLeftBoundary(ctxt, index, true);
                        }
                    }
                    return(false);
                }
                if (curIch == curTss.Length && curTag == PatternVcBase.ktagRightNonBoundary)
                {
                    // the cursor is at a non-selectable right edge of an item, so move to the
                    // selectable right edge
                    SelectRightBoundary(ctxt, index, true);
                    return(false);
                }
                if (curIch == 0 && curTag == PatternVcBase.ktagRightNonBoundary)
                {
                    // the cursor has been moved to the right from the right boundary, so move the
                    // cursor to the next item in the cell or the next cell
                    if (index < m_patternControl.GetContextCount(ctxt) - 1)
                    {
                        SelectAt(ctxt, index + 1, true, true, true);
                    }
                    else
                    {
                        object nextCtxt = m_patternControl.GetNextContext(ctxt);
                        if (nextCtxt != null)
                        {
                            SelectCell(nextCtxt, true, true);
                        }
                        else
                        {
                            SelectRightBoundary(ctxt, index, true);
                        }
                    }
                    return(false);
                }
                // when you click to the left of a ZWSP left boundary, Views might place the cursor to the right of the
                // ZWSP. Move the cursor to the proper location before the ZWSP.
                if (curTss.Text == "\u200b" && curIch == 1 && curTag == PatternVcBase.ktagLeftBoundary)
                {
                    SelectLeftBoundary(ctxt, index, true);
                    return(false);
                }

                if (!sel.Selection.IsEditable)
                {
                    return(false);
                }
            }

            // find the beginning of the currently selected item
            IVwSelection initialSel = SelectAt(ctxt, index, true, false, false);

            ITsString tss;
            int       selCellIndex = index;
            int       initialHvo, initialIch, initialTag;

            if (initialSel == null)
            {
                return(false);
            }
            initialSel.TextSelInfo(false, out tss, out initialIch, out prev, out initialHvo, out initialTag, out ws);
            // are we at the beginning of an item?
            if ((curHvo == initialHvo && curIch == initialIch && curTag == initialTag) ||
                (curIch == 0 && curTag == PatternVcBase.ktagLeftBoundary))
            {
                // if the current selection is an IP, then don't adjust anything
                if (!sel.IsRange)
                {
                    return(false);
                }

                // if we are the beginning of the current item, and the current selection is a range, and the end is before the anchor,
                // then do not include the current item in the adjusted range selection
                if (sel.Selection.EndBeforeAnchor && limit == SelectionHelper.SelLimitType.Anchor)
                {
                    selCellIndex = index - 1;
                }
            }
            else
            {
                int          finalIch, finalHvo, finalTag;
                IVwSelection finalSel = SelectAt(ctxt, index, false, false, false);
                finalSel.TextSelInfo(false, out tss, out finalIch, out prev, out finalHvo, out finalTag, out ws);
                // are we at the end of an item?
                if ((curHvo == finalHvo && curIch == finalIch && curTag == finalTag) ||
                    (curIch == curTss.Length && curTag == PatternVcBase.ktagRightBoundary))
                {
                    // if the current selection is an IP, then don't adjust anything
                    if (!sel.IsRange)
                    {
                        return(false);
                    }

                    // if we are the end of the current item, and the current selection is a range, and the anchor is before the end,
                    // then do not include the current item in the adjusted range selection
                    if (!sel.Selection.EndBeforeAnchor && limit == SelectionHelper.SelLimitType.Anchor)
                    {
                        selCellIndex = index + 1;
                    }
                }
            }

            bool initial = limit == SelectionHelper.SelLimitType.Anchor ? !sel.Selection.EndBeforeAnchor : sel.Selection.EndBeforeAnchor;

            vwSel = SelectAt(ctxt, selCellIndex, initial, false, false);

            return(vwSel != null);
        }
Esempio n. 30
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the index of the current book in the book filter, or -1 if there is no
 /// current book (e.g. no selection or empty view).
 /// </summary>
 /// <param name="selHelper">The selection helper.</param>
 /// <param name="selLimitType">Which end of the selection</param>
 /// <returns>
 /// The index of the current book, or -1 if there is no current book.
 /// </returns>
 /// ------------------------------------------------------------------------------------
 public override int GetBookIndex(SelectionHelper selHelper,
                                  SelectionHelper.SelLimitType selLimitType)
 {
     return(m_vDraft.m_bookIndex);
 }