Esempio n. 1
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="ScrVerse"/> class, when we don't
 /// care about the complete para property
 /// </summary>
 /// -----------------------------------------------------------------------------------
 public ScrVerse(BCVRef start, BCVRef end, ITsString text, ParaNodeMap map,
                 int hvoPara, int hvoParaOwner, int ichMinVerse, int ichMinText,
                 bool isChapterNumberRun, bool isVerseNumberRun) :
     this(start, end, text, map, hvoPara, hvoParaOwner, ichMinVerse, ichMinText,
          isChapterNumberRun, isVerseNumberRun, false, false)
 {
 }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a deep copy of this ParaNodeMap
        /// </summary>
        /// <returns>The copy</returns>
        /// ------------------------------------------------------------------------------------
        public ParaNodeMap Clone()
        {
            ParaNodeMap clonedMap = new ParaNodeMap();

            clonedMap.m_location = (int[])this.m_location.Clone();             // int[].Clone may only return its reference
            return(clonedMap);
        }
Esempio n. 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Compares this object against the supplied one.  Objects are compared on the
        /// basis of their location, starting from the broadest form (where they are in
        /// the book), to the most specific (which paragraph in a section are they)
        /// </summary>
        /// <param name="o">The object to compare myself to</param>
        /// <returns>
        /// The integer value signifying this object's relationship to the one given.
        /// This relationship is an expression of our relationship to the supplied object.
        /// If this one is bigger than the one given, return 1, if smaller, -1, and if they
        /// are equal, 0
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public int CompareTo(object o)
        {
            // Cast the given object and store it, so we don't have to keep casting it
            ParaNodeMap compareAgainst = (ParaNodeMap)o;

            // Walk down the list, starting at the least level of detail (the book level)
            // moving inwards towards paragraphs
            for (int i = 0; i < this.m_location.Length; i++)
            {
                // If at our current level of the depth, the object given to compare to
                // us is less than us, return 1 to show that we are bigger
                if (compareAgainst.m_location[i] < this.m_location[i])
                {
                    return(1);
                }
                // If it is greater than us, return -1
                else if (compareAgainst.m_location[i] > this.m_location[i])
                {
                    return(-1);
                }
            }

            // If the whole loop ran through and never returned, return 0
            // to signify that the objects are equal
            return(0);
        }
Esempio n. 4
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ScrVerseSet"/> class, for the given
        /// paragraph.
        /// </summary>
        /// <param name="para">given paragraph</param>
        /// -----------------------------------------------------------------------------------
        public ScrVerseSet(ScrTxtPara para)
        {
            if (para == null)
            {
                throw new ArgumentNullException("para");
            }

            m_para    = para;
            m_address = new ParaNodeMap(para);
            m_para.GetBCVRefAtPosition(0, out m_startRef, out m_endRef);
        }
Esempio n. 5
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="ScrVerse"/> class.
 /// </summary>
 /// -----------------------------------------------------------------------------------
 public ScrVerse(BCVRef start, BCVRef end, ITsString text, ParaNodeMap map,
                 int hvoPara, int hvoParaOwner, int ichMinVerse, int ichMinText,
                 bool isChapterNumberRun, bool isVerseNumberRun, bool isCompletePara, bool isStanzaBreak)
 {
     m_startRef         = new BCVRef(start);
     m_endRef           = new BCVRef(end);
     m_text             = text;
     m_address          = map;
     m_hvoPara          = hvoPara;
     m_hvoParaOwner     = hvoParaOwner;
     m_ichMinVerse      = ichMinVerse;
     m_ichMinText       = ichMinText;
     m_chapterNumberRun = isChapterNumberRun;
     m_verseNumberRun   = isVerseNumberRun;
     m_completePara     = isCompletePara;
     m_isStanzaBreak    = isStanzaBreak;
 }
Esempio n. 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Two ParaNodeMaps are considered to be equal if they indicate the same exact location
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override bool Equals(object o)
        {
            // Cast the given object and store it, so we don't have to keep casting it
            ParaNodeMap compareAgainst = (ParaNodeMap)o;

            // Walk down each list, comparing them side-by-side to see if any of the
            // elements are different
            for (int i = 0; i < this.m_location.Length; i++)
            {
                // If any of the elements in our arrays are different, return false; they aren't
                // equal unless they're equal on every element
                if (compareAgainst.m_location[i] != this.m_location[i])
                {
                    return(false);
                }
            }

            // If the whole loop ran through we know that the lists have the same values in them,
            // return true--they are equal
            return(true);
        }
Esempio n. 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Helper method for verifying a ScrVerse.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private static void VerifyScrVerse(ScrVerse scrVerse, StTxtPara para, int startRef, int endRef,
			string verseText, int iVerseStart, bool fIsChapter, bool fIsHeading, int iSection)
		{
			Assert.AreEqual(para.Hvo, scrVerse.HvoPara);
			Assert.AreEqual(startRef, scrVerse.StartRef);
			Assert.AreEqual(endRef, scrVerse.EndRef);
			Assert.AreEqual(verseText, scrVerse.Text.Text);
			Assert.AreEqual(iVerseStart, scrVerse.VerseStartIndex);
			Assert.AreEqual(fIsChapter, scrVerse.ChapterNumberRun);
			// check the ParaNodeMap too
			Assert.AreEqual((int)ScrBook.ScrBookTags.kflidSections, scrVerse.ParaNodeMap.BookFlid);
			Assert.AreEqual(iSection, scrVerse.ParaNodeMap.SectionIndex);
			Assert.AreEqual(fIsHeading ? (int)ScrSection.ScrSectionTags.kflidHeading :
				(int)ScrSection.ScrSectionTags.kflidContent, scrVerse.ParaNodeMap.SectionFlid);
			Assert.AreEqual(0, scrVerse.ParaNodeMap.ParaIndex);
			ParaNodeMap map = new ParaNodeMap(para);
			Assert.IsTrue(map.Equals(scrVerse.ParaNodeMap));
		}
Esempio n. 8
0
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="ScrVerse"/> class for an empty paragraph.
 /// </summary>
 /// -----------------------------------------------------------------------------------
 public ScrVerse(BCVRef start, BCVRef end, ITsString text, ParaNodeMap map,
                 int hvoPara, int hvoParaOwner, bool isStanzaBreak) :
     this(start, end, text, map, hvoPara, hvoParaOwner, 0, 0, false, false, true, isStanzaBreak)
 {
 }
Esempio n. 9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a deep copy of this ParaNodeMap
		/// </summary>
		/// <returns>The copy</returns>
		/// ------------------------------------------------------------------------------------
		public ParaNodeMap Clone()
		{
			ParaNodeMap clonedMap = new ParaNodeMap();
			clonedMap.m_location = (int[])this.m_location.Clone(); // int[].Clone may only return its reference
			return clonedMap;
		}