Exemple #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Advance the scripture text object enumerator to the next segment.
        /// </summary>
        /// <remarks>Virtual to support testing</remarks>
        /// <param name="sText">Set to the text of the current segment</param>
        /// <param name="sMarker">Set to the marker of the current segment tag</param>
        /// <param name="domain">Set to the domain of the stream being processed</param>
        /// <returns>True if successful. False if there are no more segments.</returns>
        /// ------------------------------------------------------------------------------------
        public virtual bool GetNextSegment(out string sText, out string sMarker,
                                           out ImportDomain domain)
        {
            domain = m_currentDomain;

            if (TypeOfImport == TypeOfImport.Paratext6)
            {
                GetNextParatextSegment(out sText, out sMarker);
                if (sMarker != null)
                {
                    return(true);
                }

                // We didn't get any segment so assume that we hit the end of the data for the book
                // ENHANCE: When we support partial book imports, this needs to change.
                m_ptCurrBook.BookNum++;
                if (m_ptCurrBook.BookNum <= m_settings.EndRef.Book)
                {
                    ResetParatextState();
                    return(GetNextSegment(out sText, out sMarker, out domain));
                }

                // We hit the end of our import range so try the next import domain
                m_ptCurrBook.BookNum = m_settings.StartRef.Book;
                switch (m_currentDomain)
                {
                case ImportDomain.Main:
                {
                    if (LoadParatextBackTranslationProject())
                    {
                        return(GetNextSegment(out sText, out sMarker, out domain));
                    }
                    goto case ImportDomain.BackTrans;
                }

                case ImportDomain.BackTrans:
                {
                    if (LoadParatextNotesProject())
                    {
                        return(GetNextSegment(out sText, out sMarker, out domain));
                    }
                    break;
                }
                }
            }
            else if (TypeOfImport == TypeOfImport.Other || TypeOfImport == TypeOfImport.Paratext5)
            {
                m_scTextSegment = m_scTextEnum.Next();
                if (m_scTextSegment != null)
                {
                    sText   = m_scTextSegment.Text;
                    sMarker = m_scTextSegment.Marker;
                    return(true);
                }
                switch (m_currentDomain)
                {
                case ImportDomain.Main:
                {
                    m_currentDomain = ImportDomain.BackTrans;
                    m_scSfmText     = new SCScriptureText(m_settings, ImportDomain.BackTrans);
                    // Now initialize the TextEnum with the range of scripture text we want
                    m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
                    return(GetNextSegment(out sText, out sMarker, out domain));
                }

                case ImportDomain.BackTrans:
                {
                    m_currentDomain = ImportDomain.Annotations;
                    m_scSfmText     = new SCScriptureText(m_settings, ImportDomain.Annotations);
                    // Now initialize the TextEnum with the range of scripture text we want
                    m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
                    return(GetNextSegment(out sText, out sMarker, out domain));
                }
                }
            }
            else
            {
                throw new Exception("GetNextSegment has an invalid import type");
            }

            sText   = null;
            sMarker = null;
            return(false);
        }
Exemple #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Advance the scripture text object enumerator to the next segment.
        /// </summary>
        /// <remarks>Virtual to support testing</remarks>
        /// <param name="sText">Set to the text of the current segment</param>
        /// <param name="sMarker">Set to the marker of the current segment tag</param>
        /// <param name="domain">Set to the domain of the stream being processed</param>
        /// <returns>True if successful. False if there are no more segments.</returns>
        /// ------------------------------------------------------------------------------------
        public virtual bool GetNextSegment(out string sText, out string sMarker,
                                           out ImportDomain domain)
        {
            int result = 0;

            domain = m_currentDomain;

            if (TypeOfImport == TypeOfImport.Paratext6)
            {
                result = m_scParatextTextEnum.Next(m_scParatextTextSegment);
                if (result != 0)
                {
                    sText   = m_scParatextTextSegment.Text;
                    sMarker = @"\" + m_scParatextTextSegment.Tag.Marker;

                    if (!ScrImportFileInfo.IsValidMarker(sMarker))
                    {
                        throw new ScriptureUtilsException(SUE_ErrorCode.InvalidCharacterInMarker, null, 0,
                                                          sMarker + sText, m_scParatextTextSegment.FirstReference.BBCCCVVV);
                    }
                    return(true);
                }
                else
                {
                    switch (m_currentDomain)
                    {
                    case ImportDomain.Main:
                    {
                        if (LoadParatextBackTranslationProject())
                        {
                            return(GetNextSegment(out sText, out sMarker, out domain));
                        }
                        goto case ImportDomain.BackTrans;
                    }

                    case ImportDomain.BackTrans:
                    {
                        if (LoadParatextNotesProject())
                        {
                            return(GetNextSegment(out sText, out sMarker, out domain));
                        }
                        break;
                    }
                    }
                }
            }
            else if (TypeOfImport == TypeOfImport.Other || TypeOfImport == TypeOfImport.Paratext5)
            {
                m_scTextSegment = m_scTextEnum.Next();
                if (m_scTextSegment != null)
                {
                    sText   = m_scTextSegment.Text;
                    sMarker = m_scTextSegment.Marker;
                    return(true);
                }
                else
                {
                    switch (m_currentDomain)
                    {
                    case ImportDomain.Main:
                    {
                        m_currentDomain = ImportDomain.BackTrans;
                        m_scSfmText     = new SCScriptureText(m_settings, ImportDomain.BackTrans);
                        // Now initialize the TextEnum with the range of scripture text we want
                        m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
                        return(GetNextSegment(out sText, out sMarker, out domain));
                    }

                    case ImportDomain.BackTrans:
                    {
                        m_currentDomain = ImportDomain.Annotations;
                        m_scSfmText     = new SCScriptureText(m_settings, ImportDomain.Annotations);
                        // Now initialize the TextEnum with the range of scripture text we want
                        m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
                        return(GetNextSegment(out sText, out sMarker, out domain));
                    }
                    }
                }
            }
            else
            {
                throw new Exception("GetNextSegment has an invalid import type");
            }

            sText   = null;
            sMarker = null;
            return(false);
        }
Exemple #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Advance the scripture text object enumerator to the next segment.
		/// </summary>
		/// <remarks>Virtual to support testing</remarks>
		/// <param name="sText">Set to the text of the current segment</param>
		/// <param name="sMarker">Set to the marker of the current segment tag</param>
		/// <param name="domain">Set to the domain of the stream being processed</param>
		/// <returns>True if successful. False if there are no more segments.</returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool GetNextSegment(out string sText, out string sMarker,
			out ImportDomain domain)
		{
			domain = m_currentDomain;

			if (TypeOfImport == TypeOfImport.Paratext6)
			{
				GetNextParatextSegment(out sText, out sMarker);
				if (sMarker != null)
					return true;

				// We didn't get any segment so assume that we hit the end of the data for the book
				// ENHANCE: When we support partial book imports, this needs to change.
				m_ptCurrBook.BookNum++;
				if (m_ptCurrBook.BookNum <= m_settings.EndRef.Book)
				{
					ResetParatextState();
					return GetNextSegment(out sText, out sMarker, out domain);
				}

				// We hit the end of our import range so try the next import domain
				m_ptCurrBook.BookNum = m_settings.StartRef.Book;
				switch (m_currentDomain)
				{
					case ImportDomain.Main:
					{
						if (LoadParatextBackTranslationProject())
							return GetNextSegment(out sText, out sMarker, out domain);
						goto case ImportDomain.BackTrans;
					}
					case ImportDomain.BackTrans:
					{
						if (LoadParatextNotesProject())
							return GetNextSegment(out sText, out sMarker, out domain);
						break;
					}
				}
			}
			else if (TypeOfImport == TypeOfImport.Other || TypeOfImport == TypeOfImport.Paratext5)
			{
				m_scTextSegment = m_scTextEnum.Next();
				if (m_scTextSegment != null)
				{
					sText = m_scTextSegment.Text;
					sMarker = m_scTextSegment.Marker;
					return true;
				}
				switch (m_currentDomain)
				{
					case ImportDomain.Main:
					{
						m_currentDomain = ImportDomain.BackTrans;
						m_scSfmText = new SCScriptureText(m_settings, ImportDomain.BackTrans);
						// Now initialize the TextEnum with the range of scripture text we want
						m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
						return GetNextSegment(out sText, out sMarker, out domain);
					}
					case ImportDomain.BackTrans:
					{
						m_currentDomain = ImportDomain.Annotations;
						m_scSfmText = new SCScriptureText(m_settings, ImportDomain.Annotations);
						// Now initialize the TextEnum with the range of scripture text we want
						m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
						return GetNextSegment(out sText, out sMarker, out domain);
					}
				}
			}
			else
				throw new Exception("GetNextSegment has an invalid import type");

			sText = null;
			sMarker = null;
			return false;
		}
Exemple #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Advance the scripture text object enumerator to the next segment.
		/// </summary>
		/// <remarks>Virtual to support testing</remarks>
		/// <param name="sText">Set to the text of the current segment</param>
		/// <param name="sMarker">Set to the marker of the current segment tag</param>
		/// <param name="domain">Set to the domain of the stream being processed</param>
		/// <returns>True if successful. False if there are no more segments.</returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool GetNextSegment(out string sText, out string sMarker,
			out ImportDomain domain)
		{
			int result = 0;
			domain = m_currentDomain;

			if (TypeOfImport == TypeOfImport.Paratext6)
			{
				result = m_scParatextTextEnum.Next(m_scParatextTextSegment);
				if (result != 0)
				{
					sText = m_scParatextTextSegment.Text;
					sMarker = @"\" + m_scParatextTextSegment.Tag.Marker;

					if (!ScrImportFileInfo.IsValidMarker(sMarker))
					{
						throw new ScriptureUtilsException(SUE_ErrorCode.InvalidCharacterInMarker, null, 0,
							sMarker + sText, m_scParatextTextSegment.FirstReference.BBCCCVVV);
					}
					return true;
				}
				else
				{
					switch (m_currentDomain)
					{
						case ImportDomain.Main:
						{
							if (LoadParatextBackTranslationProject())
								return GetNextSegment(out sText, out sMarker, out domain);
							goto case ImportDomain.BackTrans;
						}
						case ImportDomain.BackTrans:
						{
							if (LoadParatextNotesProject())
								return GetNextSegment(out sText, out sMarker, out domain);
							break;
						}
					}
				}
			}
			else if (TypeOfImport == TypeOfImport.Other || TypeOfImport == TypeOfImport.Paratext5)
			{
				m_scTextSegment = m_scTextEnum.Next();
				if (m_scTextSegment != null)
				{
					sText = m_scTextSegment.Text;
					sMarker = m_scTextSegment.Marker;
					return true;
				}
				else
				{
					switch (m_currentDomain)
					{
						case ImportDomain.Main:
						{
							m_currentDomain = ImportDomain.BackTrans;
							m_scSfmText = new SCScriptureText(m_settings, ImportDomain.BackTrans);
							// Now initialize the TextEnum with the range of scripture text we want
							m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
							return GetNextSegment(out sText, out sMarker, out domain);
						}
						case ImportDomain.BackTrans:
						{
							m_currentDomain = ImportDomain.Annotations;
							m_scSfmText = new SCScriptureText(m_settings, ImportDomain.Annotations);
							// Now initialize the TextEnum with the range of scripture text we want
							m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef);
							return GetNextSegment(out sText, out sMarker, out domain);
						}
					}
				}
			}
			else
				throw new Exception("GetNextSegment has an invalid import type");

			sText = null;
			sMarker = null;
			return false;
		}