Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SetupSelectionForRangeAcrossBooks()
        {
            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 = 31;
            anchorLevInfo[0].tag  = StTextTags.kflidParagraphs;
            anchorLevInfo[0].ihvo = 0;
            selHelper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, anchorLevInfo);
            selHelper.IchAnchor = 1;

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

            // Now that all the preparation to set the selection is done, set it.
            selHelper.SetSelection(m_footnoteView, true, true);
            Application.DoEvents();
        }
Ejemplo n.º 2
0
        protected void MakeTextSelectionAndScrollToView(int ichMin, int ichLim, int ws, int ipara, int ihvoEnd)
        {
            var rgsli = new SelLevInfo[1];

            // entry 0 says which StTextPara
            rgsli[0].ihvo = ipara;
            rgsli[0].tag  = StTextTags.kflidParagraphs;
            // entry 1 says to use the Contents of the Text.
            //rgsli[1].tag = (int)FDO.Ling.Text.TextTags.kflidContents;
            try
            {
                RootBox.MakeTextSelection(0, rgsli.Length, rgsli,
                                          StTxtParaTags.kflidContents, 0, ichMin,
                                          ichLim, ws,
                                          false, // Range, arbitrary assoc prev.
                                          ihvoEnd,
                                          null,  // don't set any special text props for typing
                                          true); // install it
                // Don't steal the focus from another window.  See FWR-1795.
                if (ParentForm == Form.ActiveForm)
                {
                    Focus();
                }
                // Scroll this selection into View.
                var sel = RootBox.Selection;
                ScrollSelectionIntoView(sel, VwScrollSelOpts.kssoDefault);
                Update();
            }
            catch (Exception)
            {
            }
        }
        private void InitSandbox()
        {
            SetSandboxSize();

            m_vc.LeftPadding = 0;
            m_rootb.Reconstruct();
            using (new HoldGraphics(this))
            {
                Rectangle rcSrcRoot;
                Rectangle rcDstRoot;
                GetCoordRects(out rcSrcRoot, out rcDstRoot);
                var rgvsli = new SelLevInfo[1];
                //rgvsli[1].ihvo = 0; // first morpheme bundle
                //rgvsli[1].tag = (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles;
                rgvsli[0].ihvo = 0;
                rgvsli[0].tag  = m_fdoCache.MetaDataCacheAccessor.GetFieldId2(CmObjectTags.kClassId, "Self", false);
                var sel = RootBox.MakeTextSelInObj(0, rgvsli.Length, rgvsli, 0, null, true, false, false, false, false);
                if (sel == null)
                {
                    Debug.WriteLine("Could not make selection in InitSandbox");
                    return;                     // can't position it accurately.
                }
                Rect rcSec;
                bool fSplit, fEndBeforeAnchor;
                sel.Location(m_graphicsManager.VwGraphics, rcSrcRoot, rcDstRoot, out m_rcPrimary, out rcSec,
                             out fSplit, out fEndBeforeAnchor);
            }
            SetPadding();
            SetSandboxLocation();
        }
Ejemplo n.º 4
0
        protected void SelectUpTo(int end1)
        {
            if (HvoRoot == 0)
            {
                return;
            }
            int end = Math.Min(end1, m_cache.GetVectorSize(HvoRoot, AnnotationListId) - 1);

            if (end < 0)
            {
                return;
            }
            if (EndSelLimitIndex > -1 && EndSelLimitIndex < end)
            {
                end = EndSelLimitIndex;
            }
            try
            {
                m_InSelectionChanged = true;
                SelLevInfo[] levelsA = new SelLevInfo[1];
                levelsA[0].ihvo = 0;
                levelsA[0].tag  = AnnotationListId;
                SelLevInfo[] levelsE = new SelLevInfo[1];
                levelsE[0].ihvo = end;
                levelsE[0].tag  = AnnotationListId;
                RootBox.MakeTextSelInObj(0, 1, levelsA, 1, levelsE, false, false, false, true, true);
            }
            finally
            {
                m_InSelectionChanged = false;
            }
        }
Ejemplo n.º 5
0
 protected void MakeTextSelectionAndScrollToView(int ichMin, int ichLim, int ws, int ihvoPara, int ihvoEnd)
 {
     SelLevInfo[] rgsli = new SelLevInfo[1];
     // entry 0 says which StTextPara
     rgsli[0].ihvo = ihvoPara;
     rgsli[0].tag  = (int)StText.StTextTags.kflidParagraphs;
     // entry 1 says to use the Contents of the Text.
     //rgsli[1].tag = (int)FDO.Ling.Text.TextTags.kflidContents;
     try
     {
         RootBox.MakeTextSelection(0, rgsli.Length, rgsli,
                                   (int)StTxtPara.StTxtParaTags.kflidContents, 0, ichMin,
                                   ichLim, ws,
                                   false, // Range, arbitrary assoc prev.
                                   ihvoEnd,
                                   null,  // don't set any special text props for typing
                                   true); // install it
         Focus();
         // Scroll this selection into View.
         IVwSelection sel = this.RootBox.Selection;
         this.ScrollSelectionIntoView(sel, VwScrollSelOpts.kssoDefault);
         Update();
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 6
0
        void VerifySelection(SandboxBase sandbox, bool fPicture, int tagText, int tagObj, int morphIndex)
        {
            Assert.That(sandbox.RootBox.Selection, Is.Not.Null);
            Assert.That(sandbox.MorphIndex, Is.EqualTo(morphIndex));
            int          ihvoRoot;
            int          tagTextProp;
            int          cpropPrevious;
            int          ichAnchor;
            int          ichEnd;
            int          ws;
            bool         fAssocPrev;
            int          ihvoEnd;
            ITsTextProps ttpBogus;

            // Main array of information retrived from sel that made combo.
            SelLevInfo[] rgvsli;
            bool         fIsPictureSel;     // icon selected.

            IVwSelection sel = sandbox.RootBox.Selection;

            fIsPictureSel = sel.SelType == VwSelType.kstPicture;
            int cvsli = sel.CLevels(false) - 1;

            rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli,
                                               out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
                                               out ws, out fAssocPrev, out ihvoEnd, out ttpBogus);
            Assert.That(fIsPictureSel, Is.EqualTo(fPicture));
            Assert.That(tagTextProp, Is.EqualTo(tagText));
            if (tagTextProp == SandboxBase.ktagSbNamedObjName)
            {
                int tagObjProp = rgvsli[0].tag;
                Assert.That(tagObjProp, Is.EqualTo(tagObj));
            }
            //sandbox.InterlinLineChoices.
        }
Ejemplo n.º 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a simulated range selection
        /// </summary>
        /// <param name="hvoPara1"></param>
        /// <param name="hvoPara2"></param>
        /// <param name="ichAnchor"></param>
        /// <param name="ichEnd"></param>
        /// ------------------------------------------------------------------------------------
        public void SetupSelectionForParas(int hvoPara1, int hvoPara2, int ichAnchor, int ichEnd)
        {
            CheckDisposed();

            DynamicMock fakeSelHelper = new DynamicMock(typeof(SelectionHelper));

            fakeSelHelper.SetupResult("NumberOfLevels", 1);
            SelLevInfo[] topInfo = new SelLevInfo[1];
            topInfo[0].tag = StTextTags.kflidParagraphs;
            topInfo[0].hvo = hvoPara1;
            SelLevInfo[] bottomInfo = new SelLevInfo[1];
            bottomInfo[0].tag = StTextTags.kflidParagraphs;
            bottomInfo[0].hvo = hvoPara2;
            fakeSelHelper.SetupResult("LevelInfo", topInfo);
            fakeSelHelper.SetupResult("IchAnchor", ichAnchor);
            fakeSelHelper.SetupResult("IchEnd", ichEnd);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", topInfo,
                                               SelectionHelper.SelLimitType.Anchor);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.Bottom);
            fakeSelHelper.SetupResultForParams("GetLevelInfo", bottomInfo,
                                               SelectionHelper.SelLimitType.End);
            fakeSelHelper.SetupResultForParams("GetIch", ichAnchor,
                                               SelectionHelper.SelLimitType.Top);
            fakeSelHelper.SetupResultForParams("GetIch", ichEnd,
                                               SelectionHelper.SelLimitType.Bottom);
            m_currentSelection = (SelectionHelper)fakeSelHelper.MockInstance;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Move to the last bundle
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        public bool OnLastBundle(object arg)
        {
            var levels = new SelLevInfo[3];

            levels[2].tag  = StTextTags.kflidParagraphs;
            levels[2].ihvo = RootStText.ParagraphsOS.Count - 1;
            var lastPara = (IStTxtPara)RootStText.ParagraphsOS.Last();

            levels[1].tag  = StTxtParaTags.kflidSegments;
            levels[1].ihvo = lastPara.SegmentsOS.Count - 1;
            ISegment lastSegment = lastPara.SegmentsOS.Last();
            int      i;

            for (i = lastSegment.AnalysesRS.Count - 1; i >= 0; i--)
            {
                if (!(lastSegment.AnalysesRS[i] is IPunctuationForm))
                {
                    break;
                }
            }
            levels[0].tag  = SegmentTags.kflidAnalyses;
            levels[0].ihvo = i;
            RootBox.MakeTextSelInObj(0, levels.Length, levels, 0, null, false, false, false, true, true);
            return(true);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Return annotation Hvo that contains the selection.
        /// </summary>
        /// <returns></returns>
        public int AnnotationContainingSelection()
        {
            Debug.Assert(m_rootb != null);
            if (m_rootb == null)
            {
                return(0);
            }
            IVwSelection sel = m_rootb.Selection;

            if (sel == null)
            {
                return(0);
            }

            // See if our selection contains a base annotation.
            int cvsli = sel.CLevels(false);

            cvsli--;             // CLevels includes the string property itself, but AllTextSelInfo doesn't need it.
            // Out variables for AllTextSelInfo.
            int          ihvoRoot, tagTextProp, cpropPrevious, ichAnchor, ichEnd, ws, ihvoEnd;
            bool         fAssocPrev;
            ITsTextProps ttpBogus;

            // Main array of information retrived from sel that made combo.
            SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli,
                                                            out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
                                                            out ws, out fAssocPrev, out ihvoEnd, out ttpBogus);

            return(FindBaseAnnInSelLevInfo(rgvsli));            // returns 0 if unsuccessful
        }
Ejemplo n.º 10
0
        private bool TryGetAnalysisLevelsAndEndLevels(IVwSelection vwselNew, out SelLevInfo[] analysisLevels, out SelLevInfo[] endLevels)
        {
            endLevels      = null;
            analysisLevels = GetAnalysisLevelsFromSelection(vwselNew);
            if (analysisLevels == null)
            {
                return(false);
            }

            var rgvsliEnd = GetOneEndPointOfSelection(vwselNew, true);

            // analysisLevels[0] contains info about the sequence of Analyses property. We want the corresponding
            // level in rgvsliEnd to have the same tag but not necessarily the same ihvo.
            // All the higher levels should be exactly the same. The loop checks this, and if successful
            // sets iend to the index of the property corresponding to analysisLevels[0].
            int iend;

            if (AreHigherLevelsSameObject(analysisLevels, rgvsliEnd, out iend))
            {
                endLevels = analysisLevels.Clone() as SelLevInfo[];
                if (endLevels != null)
                {
                    endLevels[0]      = new SelLevInfo();                // clone is SHALLOW; don't modify element of analysisLevels.
                    endLevels[0].ihvo = rgvsliEnd[iend].ihvo;
                    endLevels[0].tag  = analysisLevels[0].tag;
                }
            }
            return(endLevels != null);
        }
Ejemplo n.º 11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Selects the paragraph in the DraftView or FootnoteView associated with the style.
        /// </summary>
        /// <param name="origSelection">selection user originally made</param>
        /// <param name="view">The DraftView or FootnoteView</param>
        /// ------------------------------------------------------------------------------------
        private void SelectAssociatedPara(SelectionHelper origSelection, IVwRootSite view)
        {
            SelLevInfo paraInfoAnchor = origSelection.GetLevelInfoForTag(
                StTextTags.kflidParagraphs, SelectionHelper.SelLimitType.Top);
            SelLevInfo paraInfoEnd = origSelection.GetLevelInfoForTag(
                StTextTags.kflidParagraphs, SelectionHelper.SelLimitType.Bottom);

            if (paraInfoAnchor.hvo != m_prevPara1Hvo || paraInfoEnd.hvo != m_prevPara2Hvo)
            {
                // The selection changed paragraphs, so update the selection in the
                // DraftView or FootnoteView
                IStTxtPara      para1  = m_fdoCache.ServiceLocator.GetInstance <IStTxtParaRepository>().GetObject(paraInfoAnchor.hvo);
                IStTxtPara      para2  = m_fdoCache.ServiceLocator.GetInstance <IStTxtParaRepository>().GetObject(paraInfoEnd.hvo);
                SelectionHelper helper = MakeSelection(para1, para2, view);
                IVwSelection    sel    = helper.SetSelection(view, true, false);
                // If the selection fails then try selecting the user prompt.
                if (sel == null)
                {
                    AdjustSelectionForPrompt(helper, para1, para2);
                    sel = helper.SetSelection(view, true, false);
                }

                Debug.Assert(sel != null || ((SimpleRootSite)view).ReadOnlyView);
                m_prevPara1Hvo = paraInfoAnchor.hvo;
                m_prevPara2Hvo = paraInfoEnd.hvo;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Insert "()" into the rootbox at the current selection, then back up the selection
        /// to be between the parentheses.
        /// </summary>
        /// <param name="rootb"></param>
        public static void InsertOptionalItem(IVwRootBox rootb)
        {
            rootb.OnChar('(');
            rootb.OnChar(')');
            // Adjust the selection to be between the parentheses.
            var vwsel = rootb.Selection;
            var cvsli = vwsel.CLevels(false);

            // CLevels includes the string property itself, but AllTextSelInfo doesn't need it.
            cvsli--;
            int          ihvoRoot;
            int          tagTextProp;
            int          cpropPrevious;
            int          ichAnchor;
            int          ichEnd;
            int          ws;
            bool         fAssocPrev;
            int          ihvoEnd;
            ITsTextProps ttp;
            var          rgvsli = SelLevInfo.AllTextSelInfo(vwsel, cvsli,
                                                            out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
                                                            out ws, out fAssocPrev, out ihvoEnd, out ttp);

            Debug.Assert(ichAnchor == ichEnd);
            Debug.Assert(ichAnchor > 0);
            --ichEnd;
            --ichAnchor;
            rootb.MakeTextSelection(ihvoRoot, cvsli, rgvsli, tagTextProp, cpropPrevious,
                                    ichAnchor, ichEnd, ws, fAssocPrev, ihvoEnd, ttp, true);
        }
        public void Find_FromTop()
        {
            CheckDisposed();

            FindCollectorEnv collectorEnv = new FindCollectorEnv(m_vc,
                                                                 Cache.MainCacheAccessor, m_para1.OwnerHVO, (int)StTextFrags.kfrText,
                                                                 m_pattern, null);

            // Start at the top
            SelLevInfo[] levInfo = new SelLevInfo[1];
            levInfo[0].hvo = m_para1.Hvo;
            levInfo[0].tag = (int)StText.StTextTags.kflidParagraphs;
            m_sel          = new FindCollectorEnv.LocationInfo(levInfo,
                                                               (int)StTxtPara.StTxtParaTags.kflidContents, 0);

            VerifyFindNext(collectorEnv, m_para1.Hvo, 23, 24);
            VerifyFindNext(collectorEnv, m_para1.Hvo, 30, 31);
            VerifyFindNext(collectorEnv, m_para1.Hvo, 55, 56);
            VerifyFindNext(collectorEnv, m_para2.Hvo, 20, 21);
            VerifyFindNext(collectorEnv, m_para2.Hvo, 27, 28);
            VerifyFindNext(collectorEnv, m_para2.Hvo, 44, 45);
            VerifyFindNext(collectorEnv, m_para2.Hvo, 52, 53);
            VerifyFindNext(collectorEnv, m_para2.Hvo, 64, 65);
            Assert.IsNull(collectorEnv.FindNext(m_sel));

            // Make sure nothing got replaced by accident.
            Assert.AreEqual("This is some text so that we can test the find functionality.",
                            m_para1.Contents.Text);
            Assert.AreEqual("Some more text so that we can test the find and replace functionality.",
                            m_para2.Contents.Text);
            Assert.AreEqual("This purugruph doesn't contuin the first letter of the ulphubet.",
                            m_para3.Contents.Text);
        }
        protected override SelLevInfo[] GetLevelInfo(int cellId, int cellIndex)
        {
            SelLevInfo[] levels = null;
            if (cellIndex > -1)
            {
                switch (cellId)
                {
                case PhMetathesisRuleTags.kidxLeftSwitch:
                    cellIndex += Rule.LeftSwitchIndex;
                    break;

                case PhMetathesisRuleTags.kidxRightSwitch:
                    if (Rule.MiddleIndex != -1 && !Rule.IsMiddleWithLeftSwitch)
                    {
                        cellIndex += Rule.MiddleIndex;
                    }
                    else
                    {
                        cellIndex += Rule.RightSwitchIndex;
                    }
                    break;

                case PhMetathesisRuleTags.kidxRightEnv:
                    cellIndex += Rule.RightEnvIndex;
                    break;
                }

                levels = new SelLevInfo[1];
                levels[0].cpropPrevious = cellIndex;
                levels[0].tag           = -1;
            }
            return(levels);
        }
Ejemplo n.º 15
0
        private void SelectRange(int begin1, int end1)
        {
            if (HvoRoot == 0)
            {
                return;
            }
            int end   = Math.Min(end1, Decorator.get_VecSize(HvoRoot, OccurenceListId) - 1);
            int begin = Math.Min(begin1, end);

            if (end < 0 || begin < 0)
            {
                return;
            }
            try
            {
                m_InSelectionChanged = true;
                SelLevInfo[] levelsA = new SelLevInfo[1];
                levelsA[0].ihvo = begin;
                levelsA[0].tag  = OccurenceListId;
                SelLevInfo[] levelsE = new SelLevInfo[1];
                levelsE[0].ihvo = end;
                levelsE[0].tag  = OccurenceListId;
                RootBox.MakeTextSelInObj(0, 1, levelsA, 1, levelsE, false, false, false, true, true);
            }
            finally
            {
                m_InSelectionChanged = false;
            }
        }
Ejemplo n.º 16
0
        public void Find_FromMiddle()
        {
            using (var collectorEnv = new FindCollectorEnv(m_vc,
                                                           Cache.DomainDataByFlid, m_para1.Owner.Hvo, (int)StTextFrags.kfrText,
                                                           m_pattern, null))
            {
                // Start in the middle
                SelLevInfo[] levInfo = new SelLevInfo[1];
                levInfo[0].hvo = m_para2.Hvo;
                levInfo[0].tag = StTextTags.kflidParagraphs;
                m_sel          = new CollectorEnv.LocationInfo(levInfo, StTxtParaTags.kflidContents, 5);

                VerifyFindNext(collectorEnv, m_para2.Hvo, 20, 21);
                VerifyFindNext(collectorEnv, m_para2.Hvo, 27, 28);
                VerifyFindNext(collectorEnv, m_para2.Hvo, 44, 45);
                VerifyFindNext(collectorEnv, m_para2.Hvo, 52, 53);
                VerifyFindNext(collectorEnv, m_para2.Hvo, 64, 65);
                Assert.IsNull(collectorEnv.FindNext(m_sel));

                // Make sure nothing got replaced by accident.
                Assert.AreEqual("This is some text so that we can test the find functionality.",
                                m_para1.Contents.Text);
                Assert.AreEqual("Some more text so that we can test the find and replace functionality.",
                                m_para2.Contents.Text);
                Assert.AreEqual("This purugruph doesn't contuin the first letter of the ulphubet.",
                                m_para3.Contents.Text);
            }
        }
Ejemplo n.º 17
0
        protected void SelectUpTo(int end1)
        {
            if (HvoRoot == 0 || RootBox == null)
            {
                return;
            }
            //Debug.Assert(RootBox != null, "Why is the chart ribbon's RootBox null?");
            var end = Math.Min(end1, Decorator.get_VecSize(HvoRoot, OccurenceListId) - 1);

            if (end < 0)
            {
                return;
            }
            if (EndSelLimitIndex > -1 && EndSelLimitIndex < end)
            {
                end = EndSelLimitIndex;
            }
            try
            {
                m_InSelectionChanged = true;
                var levelsA = new SelLevInfo[1];
                levelsA[0].ihvo = 0;
                levelsA[0].tag  = OccurenceListId;
                var levelsE = new SelLevInfo[1];
                levelsE[0].ihvo = end;
                levelsE[0].tag  = OccurenceListId;
                RootBox.MakeTextSelInObj(0, 1, levelsA, 1, levelsE, false, false, false, true, true);
            }
            finally
            {
                m_InSelectionChanged = false;
            }
        }
Ejemplo n.º 18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determines if the current stack loacation and the specified tag match the location
        /// specified in the given LocationInfo
        /// </summary>
        /// <param name="info">The LocationInfo to check.</param>
        /// <param name="tag">The tag of the current property.</param>
        /// <returns>True if the location is the same, false otherwise</returns>
        /// ------------------------------------------------------------------------------------
        protected bool CurrentStackIsSameAsLocationInfo(LocationInfo info, int tag)
        {
            if (info.m_location.Length != m_stack.Count)
            {
                return(false);
            }

            // If we haven't gotten to the same occurrence of the same object property, we haven't
            // hit the starting point.
            for (int lev = 0; lev < m_stack.Count; lev++)
            {
                SelLevInfo limInfo = info.m_location[lev];
                // NOTE: the information in our m_stack variable and the information stored in
                // the selection levels are in opposite order.
                int       iourStackLev = m_stack.Count - lev - 1;
                StackItem stackInfo    = m_stack[iourStackLev];
                int       cPrevProps   = (iourStackLev > 0 ? m_stack[iourStackLev - 1].m_cpropPrev.GetCount(stackInfo.m_tag) :
                                          m_cpropPrev.GetCount(stackInfo.m_tag));

                if (limInfo.tag != stackInfo.m_tag || limInfo.cpropPrevious != cPrevProps ||
                    limInfo.hvo != stackInfo.m_hvo)
                {
                    return(false);                    // Can't be at the same location
                }
            }

            // ENHANCE: If we ever need to handle multiple root objects, we'd need to check
            // ihvoRoot here.
            return(info.m_tag == tag && info.m_cpropPrev == CPropPrev(tag));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Make one.
        /// </summary>
        public PromptSelectionRestorer(IVwRootBox rootbox)
        {
            m_rootbox = rootbox;
            if (rootbox == null)
            {
                return;
            }
            // Save information about the old selection.
            IVwSelection oldsel = rootbox.Selection;
            // Dummy variables
            int  tagTextProp;
            int  ichAnchor;
            int  ichEnd;
            int  ihvoEnd;
            bool fAssocPrev;

            if (oldsel != null && oldsel.CLevels(false) > 0)
            {
                cvsli = oldsel.CLevels(false);
                cvsli--;                 // CLevels includes the string property itself, but AllTextSelInfo doesn't need it.
                rgvsli = SelLevInfo.AllTextSelInfo(oldsel, cvsli,
                                                   out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
                                                   out ws, out fAssocPrev, out ihvoEnd, out ttp);
            }
        }
Ejemplo n.º 20
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handle Mouse up
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                base.OnMouseUp(e);
                return;
            }

            NotesMainWnd notesMainWnd = TheMainWnd as NotesMainWnd;

            if (notesMainWnd == null || notesMainWnd.TMAdapter == null)
            {
                return;
            }

            Rectangle rcSrcRoot;
            Rectangle rcDstRoot;

            GetCoordRects(out rcSrcRoot, out rcDstRoot);
            Point        pt      = new Point(e.X, e.Y);
            IVwSelection sel     = m_rootb.MakeSelAt(pt.X, pt.Y, rcSrcRoot, rcDstRoot, false);
            int          noteHvo = 0;

            if (sel != null)
            {
                SelectionHelper selHelper = SelectionHelper.Create(sel, this);
                SelLevInfo      annInfo   = selHelper.GetLevelInfoForTag(m_currentNotesTag);
                noteHvo = annInfo.hvo;
            }

            pt = PointToScreen(new Point(e.X, e.Y));
            notesMainWnd.TMAdapter.PopupMenu("cmnuNotesDataEntryView", pt.X, pt.Y);
        }
Ejemplo n.º 21
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.º 22
0
        public void ReadOnlySpaceAfterFootnoteMarker()
        {
            // Prepare the test by creating a footnote view
            FwStyleSheet styleSheet = new FwStyleSheet();

            styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

            using (Form form = new Form())
                using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache))
                {
                    footnoteView.StyleSheet = styleSheet;
                    footnoteView.Dock       = DockStyle.Fill;
                    footnoteView.Name       = "footnoteView";
                    footnoteView.Visible    = true;
                    form.Controls.Add(footnoteView);
                    form.Show();

                    try
                    {
                        // Select the footnote marker and some characters of the footnote paragraph
                        footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
                        SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
                        selHelper.IchAnchor = 0;
                        selHelper.IchEnd    = 5;
                        SelLevInfo[] selLevInfo = new SelLevInfo[3];
                        Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
                        Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
                        selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
                        selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
                                                StTxtParaTags.kflidContents);
                        selHelper.SetSelection(true);

                        // Now the real test:
                        IVwSelection sel = footnoteView.RootBox.Selection;
                        ITsString    tss;
                        sel.GetSelectionString(out tss, string.Empty);
                        Assert.AreEqual("a ", tss.Text.Substring(0, 2));

                        // make sure the marker and the space are read-only and the paragraph not.
                        ITsTextProps[]     vttp;
                        IVwPropertyStore[] vvps;
                        int cttp;
                        SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
                        Assert.IsTrue(cttp >= 3);
                        Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
                                       "Footnote marker is not read-only");
                        Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
                                       "Space after marker is not read-only");
                        Assert.IsTrue(SelectionHelper.IsEditable(vttp[2], vvps[2]),
                                      "Footnote text is read-only");
                        Assert.IsTrue(SelectionHelper.IsEditable(vttp[3], vvps[3]),
                                      "Footnote text is read-only");
                    }
                    finally
                    {
                        form.Close();
                    }
                }
        }
Ejemplo n.º 23
0
        public void DeleteFootnoteFromContextMenuRangeSelection()
        {
            CheckDisposed();

            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  = (int)ScrBook.ScrBookTags.kflidFootnotes;
            anchorLevInfo[1].ihvo = 2;
            anchorLevInfo[0].tag  = (int)StText.StTextTags.kflidParagraphs;
            anchorLevInfo[0].ihvo = 0;
            selHelper.SetLevelInfo(SelectionHelper.SelLimitType.Anchor, anchorLevInfo);
            selHelper.IchAnchor = 1;

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

            // 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.
            ScrFootnote[] footnotes     = new ScrFootnote[5];
            Guid[]        guidFootnotes = new Guid[5];
            int[]         hvoParas      = new int[5];
            for (int i = 0; i < 5; i++)
            {
                footnotes[i]     = new ScrFootnote(Cache, m_Jude.FootnotesOS.HvoArray[i + 2]);
                guidFootnotes[i] = Cache.GetGuidFromId(footnotes[i].Hvo);
                hvoParas[i]      = footnotes[i].ContainingParagraphHvo;
            }

            m_footnoteView.DeleteFootnote();

            foreach (ScrFootnote footnote in footnotes)
            {
                Assert.IsFalse(Cache.IsRealObject(footnote.Hvo, StFootnote.kClassId));
            }

            // now make sure that we don't find the footnote markers
            for (int i = 0; i < 5; i++)
            {
                VerifyRemovedFootnoteMarker(hvoParas[i], guidFootnotes[i]);
                VerifyRemovedFootnoteMarker(hvoParas[i], guidFootnotes[i], InMemoryFdoCache.s_wsHvos.En);
                VerifyRemovedFootnoteMarker(hvoParas[i], guidFootnotes[i], InMemoryFdoCache.s_wsHvos.De);
            }
        }
Ejemplo n.º 24
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Do remaining initialization once we (might) have a selection.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        void Init()
        {
            if (m_sel == null)
            {
                return;
            }
            if (m_sel.SelType == VwSelType.kstPicture)
            {
                // TextSelInfo doesn't work; but we can get a good approximation of much of the
                // information like this.
                // Out variables for AllTextSelInfo.
                int          ihvoRoot;
                int          tagTextProp;
                int          cpropPrevious;
                int          ichAnchor;
                int          ichEnd;
                int          ws;
                bool         fAssocPrev;
                int          ihvoEnd;
                ITsTextProps ttpBogus;
                // Main array of information retrieved from sel that made combo.
                SelLevInfo[] rgvsli;

                // Analysis can now be zero (e.g., displaying alternate case form for non-existent WfiWordform)
                // and I don't believe it's a problem for the code below (JohnT).
                //				if (sandbox.Analysis == 0)
                //				{
                //					// We aren't fully initialized yet, so don't do anything.
                //					return null;
                //				}
                try
                {
                    int cvsli = m_sel.CLevels(false) - 1;
                    rgvsli = SelLevInfo.AllTextSelInfo(m_sel, cvsli,
                                                       out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
                                                       out ws, out fAssocPrev, out ihvoEnd, out ttpBogus);
                }
                catch (Exception)
                {
                    // If anything goes wrong just give up.
                    return;
                }
                m_ichA = ichAnchor;
                m_ichE = ichEnd;
                if (rgvsli.Length > 0)
                {
                    m_hvoObjA = m_hvoObjE = rgvsli[0].hvo;
                }
                m_tagA = m_tagE = tagTextProp;
            }
            else
            {
                m_sel.TextSelInfo(true, out m_tssE, out m_ichE, out m_fAssocPrev, out m_hvoObjE, out m_tagE, out m_wsE);
                m_sel.TextSelInfo(false, out m_tssA, out m_ichA, out m_fAssocPrev, out m_hvoObjA, out m_tagA, out m_wsA);
            }
            m_fIsRange = m_sel.IsRange;
            m_selType  = m_sel.SelType;
        }
Ejemplo n.º 25
0
        protected VwDelProbResponse DeleteObjectFromVector(IVwSelection sel, int cvsli, int hvoObj)
        {
            int          hvoObjEnd = hvoObj;
            int          ichAnchor;
            int          ichEnd;
            bool         fAssocPrev;
            int          ws;
            int          ihvoRoot;
            int          tagTextProp;
            int          cpropPrevious;
            int          ihvoEnd;
            ITsTextProps ttp;

            SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli,
                                                            out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
                                                            out ws, out fAssocPrev, out ihvoEnd, out ttp);
            IVwSelection vwselWhole = null;

            Debug.Assert(m_rootb != null);
            // Create a selection that covers the entire target object.  If it differs from
            // the new selection, we'll install it (which will recurse back to this method).
            vwselWhole = m_rootb.MakeTextSelInObj(ihvoRoot, cvsli, rgvsli, 0, null,
                                                  false, false, false, true, false);
            if (vwselWhole != null)
            {
                ITsString tssWhole;
                int       ichAnchorWhole;
                int       ichEndWhole;
                int       hvoObjWhole;
                int       hvoObjEndWhole;
                bool      fAssocPrevWhole;
                int       tagWhole;
                int       wsWhole;
                vwselWhole.TextSelInfo(false, out tssWhole, out ichAnchorWhole,
                                       out fAssocPrevWhole, out hvoObjWhole, out tagWhole, out wsWhole);
                vwselWhole.TextSelInfo(true, out tssWhole, out ichEndWhole,
                                       out fAssocPrevWhole, out hvoObjEndWhole, out tagWhole, out wsWhole);
                if (hvoObj == hvoObjWhole && hvoObjEnd == hvoObjEndWhole &&
                    ichAnchor == ichAnchorWhole && ichEnd == ichEndWhole)
                {
                    // We've selected the whole string for it, so remove the object from the
                    // vector.
                    int[] hvosOld = m_fdoCache.GetVectorProperty(m_rootObj.Hvo, m_rootFlid,
                                                                 false);
                    UpdateTimeStampsIfNeeded(hvosOld);
                    for (int i = 0; i < hvosOld.Length; ++i)
                    {
                        if (hvosOld[i] == hvoObj)
                        {
                            RemoveObjectFromList(hvosOld, i);
                            break;
                        }
                    }
                }
            }
            return(VwDelProbResponse.kdprDone);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// checkNextLevel follows the GUI model 'level' nodes as indicated via the level path, lpath,
        /// to create a FW views navigation array to the string to be selected.
        /// If lpath does not contain a symbol for the current level, the first encountered in the
        /// GUI model is used.
        /// The last level of the GUI model must be specified to obtain a string.
        /// If not, an interop error is raised. This needs further investigation.
        /// Information from the model populates the SelLevInfo array as recursions return.
        /// </summary>
        /// <param name="viewRoot">The a GUI model view or level XML node.</param>
        /// <param name="lpath">Level path array</param>
        /// <param name="passes">The recursion count.</param>
        /// <param name="rgvsli">The FW views system navigation array.</param>
        /// <param name="clevels">Number of levels in the FW views system navigation array.</param>
        private void checkNextLevel(XmlNode viewRoot, GuiPath lpath, int passes, out SelLevInfo[] rgvsli, out int clevels)
        {
            XmlNodeList nLevelList = viewRoot.SelectNodes("level");

            isNotNull(nLevelList, "found no levels in Gui Model view.");
            XmlNode xLevel = nLevelList[0];

            lpath = lpath.Next;
            // if lpath = null, then set fisrt level only.
            if (lpath == null)
            {             // end recursion
                if (passes == 0)
                {
                    clevels = 1;
                }
                else
                {
                    clevels = passes;
                }
                rgvsli = new SelLevInfo[clevels];
                if (passes == 0)
                {                 // create at least the first level
                    rgvsli[0].ihvo          = 0;
                    rgvsli[0].tag           = Convert.ToInt32(xLevel.Attributes["flid"].Value);
                    rgvsli[0].cpropPrevious = 0;
                }
                return;
            }
            string num = "0";             //ihvo
            // Does the lpath type match a level symbol?
            // Try to get more specific by matching the user's symbol
            IEnumerator eLevel = nLevelList.GetEnumerator();
            bool        OK     = eLevel.MoveNext();

            while (OK && !((XmlNode)eLevel.Current).Attributes["symbol"].Value.Equals(lpath.Type))
            {
                OK = eLevel.MoveNext();
            }
            if (OK)
            {                        // got a match: use the level obtained
                xLevel = (XmlNode)eLevel.Current;
                num    = lpath.Name; // ihvo
            }
            checkNextLevel(xLevel, lpath, passes + 1, out rgvsli, out clevels);

            // set the rgvsli array on the way out (post recurive)
            if (num == null)
            {
                num = "0";
            }
            int indx = clevels - passes - 1;         // the array elements are reversed

            rgvsli[indx].ihvo          = Convert.ToInt32(num);
            rgvsli[indx].tag           = Convert.ToInt32(xLevel.Attributes["flid"].Value);
            rgvsli[indx].cpropPrevious = 0;
        }
Ejemplo n.º 27
0
        protected void DeleteObjectFromVector(IVwSelection sel, int cvsli, int hvoObj, string undoText, string redoText)
        {
            int          hvoObjEnd = hvoObj;
            int          ichAnchor;
            int          ichEnd;
            bool         fAssocPrev;
            int          ws;
            int          ihvoRoot;
            int          tagTextProp;
            int          cpropPrevious;
            int          ihvoEnd;
            ITsTextProps ttp;

            SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli,
                                                            out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
                                                            out ws, out fAssocPrev, out ihvoEnd, out ttp);
            Debug.Assert(m_rootb != null);
            // Create a selection that covers the entire target object.  If it differs from
            // the new selection, we'll install it (which will recurse back to this method).
            IVwSelection vwselWhole = m_rootb.MakeTextSelInObj(ihvoRoot, cvsli, rgvsli, 0, null,
                                                               false, false, false, true, false);

            if (vwselWhole != null)
            {
                ITsString tssWhole;
                int       ichAnchorWhole;
                int       ichEndWhole;
                int       hvoObjWhole;
                int       hvoObjEndWhole;
                bool      fAssocPrevWhole;
                int       tagWhole;
                int       wsWhole;
                vwselWhole.TextSelInfo(false, out tssWhole, out ichAnchorWhole,
                                       out fAssocPrevWhole, out hvoObjWhole, out tagWhole, out wsWhole);
                vwselWhole.TextSelInfo(true, out tssWhole, out ichEndWhole,
                                       out fAssocPrevWhole, out hvoObjEndWhole, out tagWhole, out wsWhole);
                if (hvoObj == hvoObjWhole && hvoObjEnd == hvoObjEndWhole &&
                    ichAnchor == ichAnchorWhole && ichEnd == ichEndWhole)
                {
                    // We've selected the whole string for it, so remove the object from the
                    // vector.
                    var hvosOld = ((ISilDataAccessManaged)m_cache.DomainDataByFlid).VecProp(m_rootObj.Hvo, m_rootFlid);
                    UpdateTimeStampsIfNeeded(hvosOld);
                    for (int i = 0; i < hvosOld.Length; ++i)
                    {
                        if (hvosOld[i] == hvoObj)
                        {
                            RemoveObjectFromList(hvosOld, i, undoText, redoText);
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 28
0
        public void SpaceAfterFootnoteMarker()
        {
            // Prepare the test by creating a footnote view
            FwStyleSheet styleSheet = new FwStyleSheet();

            styleSheet.Init(m_fdoCache, m_scr.Hvo,
                            (int)Scripture.ScriptureTags.kflidStyles);

            using (DummyFootnoteView footnoteView = new DummyFootnoteView(m_fdoCache))
            {
                footnoteView.StyleSheet = styleSheet;
                footnoteView.Visible    = false;

                // We don't actually want to show it, but we need to force the view to create the root
                // box and lay it out so that various test stuff can happen properly.
                footnoteView.MakeRoot();
                footnoteView.CallLayout();

                // Select the footnote marker and some characters of the footnote paragraph
                footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
                SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
                selHelper.IchAnchor = 0;
                selHelper.IchEnd    = 5;
                SelLevInfo[] selLevInfo = new SelLevInfo[3];
                Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
                Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
                selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
                selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
                                        (int)StTxtPara.StTxtParaTags.kflidContents);
                selHelper.SetSelection(true);

                // Now the real test:
                IVwSelection sel = footnoteView.RootBox.Selection;
                ITsString    tss;
                sel.GetSelectionString(out tss, string.Empty);
                Assert.AreEqual("a ", tss.Text.Substring(0, 2));

                //				// make sure the marker and the space are read-only and the paragraph not.
                //				ITsTextProps[] vttp;
                //				IVwPropertyStore[] vvps;
                //				int cttp;
                //				SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
                //				Assert.IsTrue(cttp >= 3);
                //				Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
                //					"Footnote marker is not read-only");
                //				Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
                //					"Space after marker is not read-only");
                //				Assert.IsTrue(SelectionHelper.IsEditable(vttp[2], vvps[2]),
                //					"Footnote text is read-only");
                //				Assert.IsTrue(SelectionHelper.IsEditable(vttp[3], vvps[3]),
                //					"Footnote text is read-only");
            }
        }
Ejemplo n.º 29
0
        public void SpaceAfterFootnoteMarker()
        {
            IScrBook     book     = m_scr.ScriptureBooksOS[0];
            IScrFootnote footnote = AddFootnote(book, (IStTxtPara)book.TitleOA.ParagraphsOS[0], 0, "This is a footnote");

            footnote.FootnoteMarker = Cache.TsStrFactory.MakeString("a", Cache.WritingSystemFactory.GetWsFromStr("en"));
            // Prepare the test by creating a footnote view
            FwStyleSheet styleSheet = new FwStyleSheet();

            styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

            using (DummyFootnoteView footnoteView = new DummyFootnoteView(Cache))
            {
                footnoteView.StyleSheet = styleSheet;
                footnoteView.Visible    = false;

                // We don't actually want to show it, but we need to force the view to create the root
                // box and lay it out so that various test stuff can happen properly.
                footnoteView.MakeRoot();
                footnoteView.CallLayout();

                // Select the footnote marker and some characters of the footnote paragraph
                footnoteView.RootBox.MakeSimpleSel(true, false, false, true);
                SelectionHelper selHelper = SelectionHelper.GetSelectionInfo(null, footnoteView);
                selHelper.IchAnchor = 0;
                selHelper.IchEnd    = 5;
                SelLevInfo[] selLevInfo = new SelLevInfo[3];
                Assert.AreEqual(4, selHelper.GetNumberOfLevels(SelectionHelper.SelLimitType.End));
                Array.Copy(selHelper.GetLevelInfo(SelectionHelper.SelLimitType.End), 1, selLevInfo, 0, 3);
                selHelper.SetLevelInfo(SelectionHelper.SelLimitType.End, selLevInfo);
                selHelper.SetTextPropId(SelectionHelper.SelLimitType.End,
                                        StTxtParaTags.kflidContents);
                selHelper.SetSelection(true);

                // Now the real test:
                IVwSelection sel = footnoteView.RootBox.Selection;
                ITsString    tss;
                sel.GetSelectionString(out tss, string.Empty);
                Assert.AreEqual("a ", tss.Text.Substring(0, 2));

                // make sure the marker and the space are read-only (maybe have to select each run
                // separately to make this test truly correct)
                ITsTextProps[]     vttp;
                IVwPropertyStore[] vvps;
                int cttp;
                SelectionHelper.GetSelectionProps(sel, out vttp, out vvps, out cttp);
                Assert.IsTrue(cttp >= 2);
                Assert.IsFalse(SelectionHelper.IsEditable(vttp[0], vvps[0]),
                               "Footnote marker is not read-only");
                Assert.IsFalse(SelectionHelper.IsEditable(vttp[1], vvps[1]),
                               "Space after marker is not read-only");
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Move to the first bundle
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        public bool OnFirstBundle(object arg)
        {
            var levels = new SelLevInfo[3];

            levels[2].tag  = StTextTags.kflidParagraphs;
            levels[2].ihvo = 0;
            levels[1].tag  = StTxtParaTags.kflidSegments;
            levels[1].ihvo = 0;
            levels[0].tag  = SegmentTags.kflidAnalyses;
            levels[0].ihvo = 0;
            RootBox.MakeTextSelInObj(0, levels.Length, levels, 0, null, false, false, false, true, true);
            return(true);
        }