Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Constructs and returns a new ScrReference representing Revelation 22:21 (or whatver
        /// the last verse is in Revelation for the current default versification scheme).
        /// </summary>
        /// <param name="versification">The versification scheme.</param>
        /// ------------------------------------------------------------------------------------
        public static ScrReference EndOfBible(Paratext.ScrVers versification)
        {
            VersificationTable versificationTable = VersificationTable.Get(versification);
            int lastChapter = versificationTable.LastChapter(LastBook);

            return(new ScrReference(LastBook, lastChapter,
                                    versificationTable.LastVerse(LastBook, lastChapter), versification));
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Checks for missing chapters.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void CheckChapterNumbers()
        {
            int bookId              = BCVRef.BookToNumber(m_sBookId);
            int lastChapInBook      = m_versification.LastChapter(bookId);
            int nextExpectedChapter = 1;
            int prevChapNumber      = 0;

            bool[] chaptersFound = new bool[lastChapInBook + 1];

            foreach (ChapterToken chapToken in m_chapTokens)
            {
                if (m_nChapterToCheck != 0 && chapToken.ChapterNumber != m_nChapterToCheck)
                {
                    continue;
                }

                string     msg      = null;
                int        errorArg = chapToken.ChapterNumber;
                ITextToken token    = chapToken.Token;

                if (!chapToken.Valid)
                {
                    // Chapter number is invalid
                    AddError(token, 0, token.Text.Length, Localize("Invalid chapter number"), errorArg);
                }

                if (chapToken.ChapterNumber >= 1)
                {
                    if (chapToken.ChapterNumber > lastChapInBook)
                    {
                        // Chapter number is out of range
                        msg = Localize("Chapter number out of range");
                    }
                    else if (chapToken.ChapterNumber == prevChapNumber)
                    {
                        // Chapter number is repeated
                        msg = Localize("Duplicate chapter number");
                    }
                    else if (chapToken.ChapterNumber < nextExpectedChapter)
                    {
                        // Chapter number is out of order
                        msg      = Localize("Chapter out of order; expected chapter {0}");
                        errorArg = nextExpectedChapter;
                    }

                    if (msg != null)
                    {
                        AddError(token, 0, token.Text.Length, msg, errorArg);
                    }
                    else
                    {
                        chaptersFound[chapToken.ChapterNumber] = true;
                        CheckVerseNumbers(chapToken, bookId);
                    }
                }

                prevChapNumber      = chapToken.ChapterNumber;
                nextExpectedChapter =
                    Math.Max(chapToken.ChapterNumber + 1, nextExpectedChapter);
            }

            CheckForMissingChapters(chaptersFound);
        }