示例#1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Creates a <see cref="ScrImportFileInfo"/> based on a file. This is used to build an
 /// in-memory list of files.
 /// </summary>
 /// <param name="fileName">Name of the file whose info this represents</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The writing system identifier of the source to which this file
 /// belongs (null for Scripture source)</param>
 /// <param name="noteType">The CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 public virtual IScrImportFileInfo Create(string fileName, ScrMappingList mappingList,
                                          ImportDomain domain, string wsId, ICmAnnotationDefn noteType,
                                          bool scanInlineBackslashMarkers)
 {
     return(new ScrImportFileInfo(fileName, mappingList, domain, wsId, noteType,
                                  scanInlineBackslashMarkers));
 }
示例#2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Resets the in use flags to false for all mappings in the list.
 /// Use this for non-Paratext 6.
 /// </summary>
 /// <param name="importDomain">Import domain</param>
 /// <param name="icuLocale">ICU locale of the import source</param>
 /// <param name="hvoNoteType">ID of the default note type for the import source</param>
 /// ------------------------------------------------------------------------------------
 internal void ResetInUseFlags(ImportDomain importDomain, string icuLocale, int hvoNoteType)
 {
     foreach (ImportMappingInfo mapping in m_list.Values)
     {
         mapping.SetIsInUse(importDomain, icuLocale, hvoNoteType, false);
     }
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Resets the in use flags to false for all mappings in the list.
 /// Use this for Paratext 6.
 /// </summary>
 /// <param name="importDomain">Import domain</param>
 /// ------------------------------------------------------------------------------------
 internal void ResetInUseFlags(ImportDomain importDomain)
 {
     foreach (ImportMappingInfo mapping in m_list.Values)
     {
         mapping.SetIsInUse(importDomain, false);
     }
 }
示例#4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo from a CmFile. This is used when populating the
 /// file list from the database.
 /// </summary>
 /// <param name="file">The CmFile</param>
 /// <param name="mappingList">List of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The ICU locale of the source to which this file belongs
 /// (null for Scripture source)</param>
 /// <param name="noteType">The CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 internal ScrImportFileInfo(ICmFile file, ScrMappingList mappingList, ImportDomain domain,
                            string wsId, ICmAnnotationDefn noteType, bool scanInlineBackslashMarkers) :
     this(file.AbsoluteInternalPath, mappingList, domain, wsId, noteType,
          scanInlineBackslashMarkers)
 {
     m_file = file;
 }
示例#5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ScrSfFileList"/> class based on an
        /// existing ScrImportSFFiles in the DB.
        /// </summary>
        /// <param name="source">A DB-based collection of Standard Format files</param>
        /// <param name="mappingList">The mapping list to which mappings will be added if any
        /// new ones are found when scanning the files</param>
        /// <param name="importDomain">Main (vernacular Scripture), BT or Annotations</param>
        /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
        /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
        /// must start on a new line, but Paratext considers all backslashes in the data to be
        /// SF markers.)</param>
        /// ------------------------------------------------------------------------------------
        public ScrSfFileList(IScrImportSFFiles source, ScrMappingList mappingList,
                             ImportDomain importDomain, bool scanInlineBackslashMarkers)
            : this(null)
        {
            var deleteList = new List <ICmFile>();
            // Load the files into an in-memory list
            foreach (ICmFile file in source.FilesOC)
            {
                try
                {
                    IScrImportFileInfo info = new ScrImportFileInfo(file, mappingList, importDomain,
                                                                    source.WritingSystem, source.NoteTypeRA, scanInlineBackslashMarkers);
                    Add(info);
                }
                catch (ScriptureUtilsException e)
                {
                    var userAction = source.Services.GetInstance <IFdoUI>();
                    userAction.DisplayMessage(MessageType.Error, string.Format(ScrFdoResources.kstidImportBadFile, e.Message), Strings.ksErrorCaption, e.HelpTopic);
                    deleteList.Add(file);
                }
            }

            // delete all of the files that caused errors
            foreach (ICmFile deleteItem in deleteList)
            {
                source.FilesOC.Remove(deleteItem);
            }

            m_modified = false;
        }
示例#6
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo from a CmFile. This is used when populating the
 /// file list from the database.
 /// </summary>
 /// <param name="file">The CmFile</param>
 /// <param name="mappingList">List of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="icuLocale">The ICU locale of the source to which this file belongs
 /// (null for Scripture source)</param>
 /// <param name="noteTypeHvo">The HVO of the CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 public ScrImportFileInfo(ICmFile file, ScrMappingList mappingList, ImportDomain domain,
                          string icuLocale, int noteTypeHvo, bool scanInlineBackslashMarkers) :
     this(file.AbsoluteInternalPath, mappingList, domain, icuLocale, noteTypeHvo,
          scanInlineBackslashMarkers)
 {
     m_file = file;
 }
示例#7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="ScrSfFileList"/> class based on an
        /// existing ScrImportSFFiles in the DB.
        /// </summary>
        /// <param name="source">A DB-based collection of Standard Format files</param>
        /// <param name="mappingList">The mapping list to which mappings will be added if any
        /// new ones are found when scanning the files</param>
        /// <param name="importDomain">Main (vernacular Scripture), BT or Annotations</param>
        /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
        /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
        /// must start on a new line, but Paratext considers all backslashes in the data to be
        /// SF markers.)</param>
        /// <param name="helpFile">The path of the application help file.</param>
        /// ------------------------------------------------------------------------------------
        public ScrSfFileList(ScrImportSFFiles source, ScrMappingList mappingList,
                             ImportDomain importDomain, bool scanInlineBackslashMarkers, string helpFile) : this(null)
        {
            List <int> deleteList = new List <int>();
            // Load the files into an in-memory list
            foreach (ICmFile file in source.FilesOC)
            {
                try
                {
                    ScrImportFileInfo info = new ScrImportFileInfo(file, mappingList, importDomain,
                                                                   source.ICULocale, source.NoteTypeRAHvo, scanInlineBackslashMarkers);
                    Add(info);
                }
                catch (ScriptureUtilsException e)
                {
                    MessageBox.Show(string.Format(ScrFdoResources.kstidImportBadFile, e.Message), "", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0, helpFile, HelpNavigator.Topic, e.HelpTopic);
                    deleteList.Add(file.Hvo);
                }
            }

            // delete all of the files that caused errors
            foreach (int deleteItem in deleteList)
            {
                source.Cache.DeleteObject(deleteItem);
            }

            m_modified = false;
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Construct a DummyScrImportFileInfo.
		/// </summary>
		/// <param name="fileName">Name of the file whose info this represents</param>
		/// <param name="domain">The import domain to which this file belongs</param>
		/// <param name="icuLocale">The ICU locale of the source to which this file belongs
		/// (null for Scripture source)</param>
		/// <param name="noteType">The CmAnnotationDefn of the source to which this file belongs
		/// (only used for Note sources)</param>
		/// <param name="booksInFile">A list of integers representing 1-based canonical book
		/// numbers that are in this file</param>
		/// <param name="fileEncoding">The file encoding</param>
		/// <param name="startRef">The first reference encountered in the file</param>
		/// ------------------------------------------------------------------------------------
		public DummyScrImportFileInfo(string fileName, ImportDomain domain, string icuLocale,
			ICmAnnotationDefn noteType, List<int> booksInFile, Encoding fileEncoding, ScrReference startRef) :
			base(fileName, null, domain, icuLocale, noteType, false)
		{
			m_booksInFile = booksInFile;
			m_fileEncoding = fileEncoding;
			m_startRef = startRef;
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a DummyScrImportFileInfo.
 /// </summary>
 /// <param name="fileName">Name of the file whose info this represents</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="icuLocale">The ICU locale of the source to which this file belongs
 /// (null for Scripture source)</param>
 /// <param name="noteTypeHvo">The HVO of the CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="booksInFile">A list of integers representing 1-based canonical book
 /// numbers that are in this file</param>
 /// <param name="fileEncoding">The file encoding</param>
 /// <param name="startRef">The first reference encountered in the file</param>
 /// ------------------------------------------------------------------------------------
 public DummyScrImportFileInfo(string fileName, ImportDomain domain, string icuLocale,
                               int noteTypeHvo, List <int> booksInFile, Encoding fileEncoding, ScrReference startRef) :
     base(fileName, null, domain, icuLocale, noteTypeHvo, false)
 {
     m_booksInFile  = booksInFile;
     m_fileEncoding = fileEncoding;
     m_startRef     = startRef;
 }
示例#10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:SegmentInfo"/> class.
		/// </summary>
		/// <param name="sMarker">The segment marker.</param>
		/// <param name="sText">The segment text.</param>
		/// <param name="domain">The import domain.</param>
		/// <param name="reference">The current Scripture reference.</param>
		/// <param name="ws">The writing system (-1 to indicate the default WS).</param>
		/// ------------------------------------------------------------------------------------
		internal SegmentInfo(string sMarker, string sText, ImportDomain domain,
			BCVRef reference, int ws)
		{
			m_sMarker = sMarker;
			m_sText = sText;
			m_domain = domain;
			m_ref = reference;
			m_ws = ws;
		}
示例#11
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Load the P6 notes project if it is specified and is to be included
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected bool LoadParatextNotesProject()
 {
     if (m_settings.ParatextNotesProj == null || !m_settings.ImportAnnotations)
     {
         return(false);
     }
     m_currentDomain = ImportDomain.Annotations;
     LoadParatextProject(m_settings.ParatextNotesProj);
     return(true);
 }
示例#12
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Load the P6 vernacular project if it is specified and is to be included
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected bool LoadParatextVernacularProject()
 {
     if (m_settings.ParatextScrProj == null)
     {
         return(false);
     }
     m_currentDomain = ImportDomain.Main;
     LoadParatextProject(m_settings.ParatextScrProj);
     return(true);
 }
示例#13
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Load the P6 Back translation project if it is specified and is to be included
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected bool LoadParatextBackTranslationProject()
 {
     if (m_settings.ParatextBTProj == null ||
         !(m_settings.ImportBackTranslation || m_settings.ImportAnnotations))
     {
         return(false);
     }
     m_currentDomain = ImportDomain.BackTrans;
     LoadParatextProject(m_settings.ParatextBTProj);
     return(true);
 }
示例#14
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo based on a filename. This is used to build an
 /// in-memory list of files.
 /// </summary>
 /// <param name="fileName">Name of the file whose info this represents</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="icuLocale">The ICU locale of the source to which this file belongs
 /// (null for Scripture source)</param>
 /// <param name="noteTypeHvo">The HVO of the CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 public ScrImportFileInfo(string fileName, ScrMappingList mappingList, ImportDomain domain,
                          string icuLocale, int noteTypeHvo, bool scanInlineBackslashMarkers)
 {
     m_fileName                 = fileName;
     m_mappingList              = mappingList;
     m_domain                   = domain;
     m_icuLocale                = icuLocale;
     m_noteTypeHvo              = noteTypeHvo;
     m_doStrictFileChecking     = false;
     ScanInlineBackslashMarkers = scanInlineBackslashMarkers;
     Initialize();
 }
示例#15
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo based on a filename. This is used to build an
 /// in-memory list of files.
 /// </summary>
 /// <param name="fileName">Name of the file whose info this represents</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The writing system identifier of the source to which this file
 /// belongs (null for Scripture source)</param>
 /// <param name="noteType">The CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 public ScrImportFileInfo(string fileName, ScrMappingList mappingList, ImportDomain domain,
                          string wsId, ICmAnnotationDefn noteType, bool scanInlineBackslashMarkers)
 {
     m_fileName                 = fileName;
     m_mappingList              = mappingList;
     m_domain                   = domain;
     m_wsId                     = wsId;
     m_noteType                 = noteType;
     m_doStrictFileChecking     = false;
     ScanInlineBackslashMarkers = scanInlineBackslashMarkers;
     Initialize();
 }
示例#16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style name
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string wsId, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
		{
			m_beginMarker = beginMarker;
			m_endMarker = endMarker;
			m_isExcluded = isExcluded;
			m_mappingTarget = mappingTarget;
			m_domain = domain;
			m_styleName = styleName;
			m_style = null;
			m_wsId = wsId;
			m_noteType = noteType;
			if (isInUse)
			{
				m_inUse[ScriptureServices.CreateImportSourceKey(importDomain, wsId,
					noteType)] = isInUse;
			}
		}
示例#17
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="SCTextEnum"/> class.
        /// </summary>
        /// <param name="settings">The import settings</param>
        /// <param name="domain">The source domain</param>
        /// <param name="startRef">first reference to retrieve</param>
        /// <param name="endRef">last reference to retrieve</param>
        /// ------------------------------------------------------------------------------------
        public SCTextEnum(IScrImportSet settings, ImportDomain domain,
                          BCVRef startRef, BCVRef endRef)
        {
            m_settings   = settings;
            m_domain     = domain;
            m_startRef   = new BCVRef(startRef);
            m_endRef     = new BCVRef(endRef);
            m_mappingSet = ((ScrImportSet)m_settings).GetMappingSetForDomain(domain);

            // Gets the set of encoding converters
            m_encConverters = new EncConverters();

            // make a list of all of the begin and end markers for inline markers
            // Also build the map of encoding converters
            m_InlineBeginAndEndMarkers = new List <string>();
            foreach (ImportMappingInfo mapping in ((ScrImportSet)m_settings).GetMappingListForDomain(domain))
            {
                if (mapping.IsInline || m_settings.ImportTypeEnum == TypeOfImport.Paratext5)
                {
                    m_InlineBeginAndEndMarkers.Add(mapping.BeginMarker);
                    if (mapping.IsInline)
                    {
                        m_InlineBeginAndEndMarkers.Add(mapping.EndMarker);
                    }
                }
            }

            m_InlineBeginAndEndMarkers.Sort(new LengthComparer());

            // Build a list of all of the characters that inline markers start with
            Set <char> tempCharList = new Set <char>();

            foreach (string marker in m_InlineBeginAndEndMarkers)
            {
                tempCharList.Add(marker[0]);                 // Set ignores duplicates.
            }
            m_InlineMarkerStartChars = tempCharList.ToArray();
            // Get the import file source that will provide the files to import.
            m_importSource     = ((ScrImportSet)settings).GetImportFiles(domain);
            m_importSourceEnum = m_importSource.GetEnumerator();
        }
示例#18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="SCTextEnum"/> class.
		/// </summary>
		/// <param name="settings">The import settings</param>
		/// <param name="domain">The source domain</param>
		/// <param name="startRef">first reference to retrieve</param>
		/// <param name="endRef">last reference to retrieve</param>
		/// <param name="encConverters">The encoding converters repository</param>
		/// ------------------------------------------------------------------------------------
		public SCTextEnum(IScrImportSet settings, ImportDomain domain,
			BCVRef startRef, BCVRef endRef, IEncConverters encConverters)
		{
			m_settings = settings;
			m_domain = domain;
			m_startRef = new BCVRef(startRef);
			m_endRef = new BCVRef(endRef);
			m_mappingSet = m_settings.GetMappingSetForDomain(domain);

			// Gets the set of encoding converters
			m_encConverters = encConverters;

			// make a list of all of the begin and end markers for inline markers
			// Also build the map of encoding converters
			m_InlineBeginAndEndMarkers = new List<string>();
			foreach (ImportMappingInfo mapping in m_settings.GetMappingListForDomain(domain))
			{
				if (mapping.IsInline || m_settings.ImportTypeEnum == TypeOfImport.Paratext5)
				{
					m_InlineBeginAndEndMarkers.Add(mapping.BeginMarker);
					if (mapping.IsInline)
						m_InlineBeginAndEndMarkers.Add(mapping.EndMarker);
				}
			}

			m_InlineBeginAndEndMarkers.Sort(new StrLengthComparer(false));

			// Build a list of all of the characters that inline markers start with
			Set<char> tempCharList = new Set<char>();
			foreach (string marker in m_InlineBeginAndEndMarkers)
				tempCharList.Add(marker[0]); // Set ignores duplicates.

			m_InlineMarkerStartChars = tempCharList.ToArray();
			// Get the import file source that will provide the files to import.
			m_importSource = settings.GetImportFiles(domain);
			m_importSourceEnum = m_importSource.GetEnumerator();
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style name
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string wsId, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
 {
     m_beginMarker   = beginMarker;
     m_endMarker     = endMarker;
     m_isExcluded    = isExcluded;
     m_mappingTarget = mappingTarget;
     m_domain        = domain;
     m_styleName     = styleName;
     m_style         = null;
     m_wsId          = wsId;
     m_noteType      = noteType;
     if (isInUse)
     {
         m_inUse[ScriptureServices.CreateImportSourceKey(importDomain, wsId,
                                                         noteType)] = isInUse;
     }
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Sets flag to indicate whether this mapping's begin marker is in use in the given
 /// import domain -- Use this version only for Paratext 6.
 /// </summary>
 /// <param name="importDomain">Import domain</param>
 /// <param name="value"><c>true</c> if the marker is in use</param>
 /// ------------------------------------------------------------------------------------
 public void SetIsInUse(ImportDomain importDomain, bool value)
 {
     m_inUse[importDomain] = value;
 }
示例#21
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Add a default mapping for the given Standard Format marker if it does not exist yet.
        /// </summary>
        /// <param name="marker">The SF marker</param>
        /// <param name="endMarker">The end marker (or null)</param>
        /// <param name="importDomain">The import domain from which this marker originates</param>
        /// <param name="fAutoMapBtMarkers">Indicates whether markers beginning with "bt" should
        /// be treated as back-translation markers if possible.</param>
        /// <param name="isInUse">Indicates whether this marker is actually in use in one or more
        /// of the import files (for P6, this is currently always false since we're getting the
        /// markers from the STY file -- we come back in a second pass and set it to true if we
        /// find it in a file).</param>
        /// <returns>The newly added mapping info, or the existing one if already in the list
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public ImportMappingInfo AddDefaultMappingIfNeeded(string marker, string endMarker,
                                                           ImportDomain importDomain, bool fAutoMapBtMarkers, bool isInUse)
        {
            // Look for the marker - if it is found, then we are done
            if (this[marker] != null)
            {
                return(this[marker]);
            }

            // Read the TEStyles XML file to generate a table of mappings
            if (s_defaultMappings.Count == 0)
            {
                ReadDefaultMappings();
            }

            string            styleName;
            bool              excluded;
            MappingTargetType target;
            MarkerDomain      markerDomain = (importDomain != ImportDomain.BackTrans) ?
                                             MarkerDomain.Default : MarkerDomain.BackTrans;

            if (importDomain == ImportDomain.Annotations)
            {
                // TODO (TE-5004): Map \rem (and possibly other markers?) automatically in annotations
                // domain. Probably need to have a separate import mapping set in TeStyles.xml that has
                // default mappings for the Annotations domain.
                styleName = null;
                excluded  = s_defaultExclusions.ContainsKey(marker);                //Make sure to check exclusions (TE-5703)
                target    = MappingTargetType.TEStyle;
            }
            else if (!GetDefaultMapping(marker, out styleName, out excluded, out target, ref markerDomain))
            {
                if (fAutoMapBtMarkers && importDomain == ImportDomain.Main &&
                    marker.StartsWith(@"\bt") && marker != @"\btc")
                {
                    // pick out the corresponding vernacular marker. "\btblah" -> "\blah"
                    string correspondingVernMarker = marker.Remove(1, 2);

                    // if domain is DeprecatedScripture and the corresponding vernacular marker is defined...
                    ImportMappingInfo correspondingVernMarkerInfo = this[correspondingVernMarker];
                    if (correspondingVernMarkerInfo != null &&
                        (correspondingVernMarkerInfo.Domain & MarkerDomain.DeprecatedScripture) != 0)
                    {
                        // clear the DeprecatedScripture bit.
                        correspondingVernMarkerInfo.Domain ^= MarkerDomain.DeprecatedScripture;
                    }
                    if (correspondingVernMarkerInfo != null)
                    {
                        // If the corresponding vernacular marker is already defined...
                        if (correspondingVernMarkerInfo.Domain != MarkerDomain.Note &&
                            (correspondingVernMarkerInfo.Domain & MarkerDomain.BackTrans) == 0 &&
                            (correspondingVernMarkerInfo.MappingTarget != MappingTargetType.TEStyle ||
                             correspondingVernMarkerInfo.StyleName != null))
                        {
                            styleName    = correspondingVernMarkerInfo.StyleName;
                            target       = correspondingVernMarkerInfo.MappingTarget;
                            markerDomain = correspondingVernMarkerInfo.Domain;

                            // We only want to map to the BackTrans domain when mapping to a paragraph
                            // style because character styles automatically assume the domain of their
                            // containing paragraphs.
                            if (m_stylesheet == null || styleName == null ||
                                m_stylesheet.GetType(styleName) == (int)StyleType.kstParagraph)
                            {
                                markerDomain |= MarkerDomain.BackTrans;
                            }
                        }
                    }
                    else if (GetDefaultMapping(correspondingVernMarker, out styleName, out excluded, out target,
                                               ref markerDomain))
                    {
                        // The corresponding vernacular marker has default mapping info so make this marker
                        // a back translation of it - unless it is an annotation or BT.
                        if (markerDomain == MarkerDomain.Note || markerDomain == MarkerDomain.BackTrans)
                        {
                            styleName    = null;
                            excluded     = false;
                            target       = MappingTargetType.TEStyle;
                            markerDomain = MarkerDomain.Default;
                        }
                        else
                        {
                            markerDomain |= MarkerDomain.BackTrans;
                        }
                    }
                }
            }
            // Create a mapping for the marker using the default mapping
            ImportMappingInfo newMapping = new ImportMappingInfo(marker, endMarker, excluded, target,
                                                                 markerDomain, styleName, null, null, isInUse, importDomain);

            Add(newMapping);
            return(newMapping);
        }
示例#22
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo from a CmFile owned by a BT source. This is
 /// used when populating the file list from the database.
 /// </summary>
 /// <param name="file">The CmFile</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The ICU locale of the source to which this file belongs
 /// (null for Scripture source)</param>
 /// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
 /// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
 /// must start on a new line, but Paratext considers all backslashes in the data to be
 /// SF markers.)</param>
 /// ------------------------------------------------------------------------------------
 internal ScrImportFileInfo(ICmFile file, ScrMappingList mappingList, ImportDomain domain,
                            string wsId, bool scanInlineBackslashMarkers) :
     this(file, mappingList, domain, wsId, null, scanInlineBackslashMarkers)
 {
 }
示例#23
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Calls the FinalizePrevSection() method.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal void CallFinalizePrevSection(IScrSection section,
			ImportDomain prevImportDomain, bool fInScriptureText)
		{
			m_currSection = section;
			m_prevImportDomain = prevImportDomain;
			m_fInScriptureText = fInScriptureText;
			m_fCurrentSectionIsIntro = section.IsIntro;
			m_sectionHeading = section.HeadingOA;
			m_sectionContent = section.ContentOA;
			FinalizePrevSection();
		}
示例#24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="SCScriptureText"/> class.
		/// </summary>
		/// <param name="settings">The import settings</param>
		/// <param name="domain">The source domain</param>
		/// ------------------------------------------------------------------------------------
		public SCScriptureText(IScrImportSet settings, ImportDomain domain)
		{
			Debug.Assert(settings != null);
			m_settings = settings;
			m_domain = domain;
		}
示例#25
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Load the mappings for a paratext project into the specified list.
        /// </summary>
        /// <param name="project">Paratext project ID</param>
        /// <param name="mappingList">ScrMappingList to which new mappings will be added</param>
        /// <param name="domain">The import domain for which this project is the source</param>
        /// <returns><c>true</c> if the Paratext mappings were loaded successfully; <c>false</c>
        /// otherwise</returns>
        /// ------------------------------------------------------------------------------------
        public static bool LoadParatextMappings(string project, ScrMappingList mappingList,
                                                ImportDomain domain)
        {
            // If the new project ID is null, then do not load mappings.
            if (project == null)
            {
                return(false);
            }

            // Load the tags from the paratext project and create mappings for them.
            SCRIPTUREOBJECTSLib.ISCScriptureText3 scParatextText = null;
            try
            {
                scParatextText = new SCRIPTUREOBJECTSLib.SCScriptureTextClass();
                scParatextText.Load(project);
            }
            catch (Exception ex)
            {
                Logger.WriteEvent(string.Format(
                                      "Got {0} exception loading paratext mappings (ScrImportP6Project.LoadParatextMappings):\n{1}",
                                      ex.GetType(), ex.Message));
                return(false);
            }

            // TE-5802
            try
            {
                for (int i = 0; true; i++)
                {
                    SCRIPTUREOBJECTSLib.ISCTag tag = scParatextText.NthTag(i);
                    if (tag == null)
                    {
                        break;
                    }
                    string marker    = @"\" + tag.Marker;
                    string endMarker = string.Empty;
                    if (tag.Endmarker != string.Empty && tag.Endmarker != null)
                    {
                        endMarker = @"\" + tag.Endmarker;
                    }

                    // When the nth marker has an end marker, the nth + 1 marker will be
                    // that end marker. Therefore, we have to skip those "end style" markers.
                    if (tag.StyleType == SCRIPTUREOBJECTSLib.SCStyleType.scEndStyle)
                    {
                        continue;
                    }

                    // Create a new mapping for this marker.
                    mappingList.AddDefaultMappingIfNeeded(marker, endMarker, domain, false, false);
                }
                SCRIPTUREOBJECTSLib.SCReference startRefPT = new SCRIPTUREOBJECTSLib.SCReference();
                SCRIPTUREOBJECTSLib.SCReference endRefPT   = new SCRIPTUREOBJECTSLib.SCReference();
                startRefPT.Parse("GEN 1:0");
                endRefPT.Parse("REV 22:21");
                SCRIPTUREOBJECTSLib.ISCTextEnum scParatextTextEnum = scParatextText.TextEnum(
                    (SCRIPTUREOBJECTSLib.SCReference)startRefPT, (SCRIPTUREOBJECTSLib.SCReference)endRefPT,
                    (SCRIPTUREOBJECTSLib.SCTextType) 0,                    //scTitle | scSection | scVerseText | scNoteText | scOther)
                    (SCRIPTUREOBJECTSLib.SCTextProperties) 0);

                SCRIPTUREOBJECTSLib.SCTextSegment scParatextTextSegment = new SCRIPTUREOBJECTSLib.SCTextSegmentClass();
                mappingList.ResetInUseFlags(domain);

                while (scParatextTextEnum.Next(scParatextTextSegment) != 0)
                {
                    string            sMarker = @"\" + scParatextTextSegment.Tag.Marker;
                    ImportMappingInfo mapping = mappingList[sMarker];
                    if (mapping != null)
                    {
                        mapping.SetIsInUse(domain, true);
                    }

                    // ENHANCE (TE-4408): Consider Detecting markers that occur in the data but are missing
                    // from the STY file. How can we write a test for this?
                    //else if (ScrImportFileInfo.IsValidMarker(sMarker))
                    //{
                    //    mappingList.AddDefaultMappingIfNeeded(sMarker,domain, false, true);
                    //}
                    //else
                    //{
                    //    throw new ScriptureUtilsException(SUE_ErrorCode.InvalidCharacterInMarker, null, 0,
                    //        sMarker + sText, new ScrReference(scParatextTextSegment.FirstReference.BBCCCVVV));
                    //}
                }
            }
            catch (Exception ex)
            {
                Logger.WriteEvent(string.Format(
                                      "Got {0} exception loading paratext mappings (ScrImportP6Project.LoadParatextMappings):\n{1}",
                                      ex.GetType(), ex.Message));
                return(false);
            }

            return(true);
        }
示例#26
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets flag to indicate whether this mapping's begin marker is in use in the given
		/// import domain -- Use this version only for Paratext 6.
		/// </summary>
		/// <param name="importDomain">Import domain</param>
		/// <param name="value"><c>true</c> if the marker is in use</param>
		/// ------------------------------------------------------------------------------------
		public void SetIsInUse(ImportDomain importDomain, bool value)
		{
			m_inUse[importDomain] = value;
		}
示例#27
0
            private bool LoadProjectMappings(string project, ScrMappingList mappingList, ImportDomain domain)
            {
                // If the new project ID is null, then do not load mappings.
                if (string.IsNullOrEmpty(project))
                {
                    return(false);
                }

                // Load the tags from the paratext project and create mappings for them.
                IScrText scParatextText;

                try
                {
                    // ParatextShared has a static collection that is responsible for the dispose of any IScrText objects
                    scParatextText = ScriptureProvider.Get(project);
                }
                catch (Exception ex)
                {
                    Logger.WriteError(ex);
                    m_IsParatextInitialized = false;
                    return(false);
                }

                foreach (ImportMappingInfo mapping in mappingList)
                {
                    mapping.SetIsInUse(domain, false);
                }
                try
                {
                    foreach (var tag in scParatextText.DefaultStylesheet.Tags)
                    {
                        if (tag == null)
                        {
                            break;
                        }
                        string marker    = @"\" + tag.Marker;
                        string endMarker = string.Empty;
                        if (!string.IsNullOrEmpty(tag.Endmarker))
                        {
                            endMarker = @"\" + tag.Endmarker;
                        }

                        // When the nth marker has an end marker, the nth + 1 marker will be
                        // that end marker. Therefore, we have to skip those "end style" markers.
                        if (tag.StyleType == ScrStyleType.scEndStyle)
                        {
                            continue;
                        }

                        // Create a new mapping for this marker.
                        mappingList.AddDefaultMappingIfNeeded(marker, endMarker, domain, false, false);
                    }
                    var parser = scParatextText.Parser;
                    foreach (int bookNum in scParatextText.BooksPresentSet.SelectedBookNumbers)
                    {
                        foreach (var token in parser.GetUsfmTokens(ScriptureProvider.MakeVerseRef(bookNum, 0, 0), false, true))
                        {
                            if (token.Marker == null)
                            {
                                continue;                                 // Tokens alternate between text and marker types
                            }
                            ImportMappingInfo mapping = mappingList[@"\" + token.Marker];
                            if (mapping != null)
                            {
                                mapping.SetIsInUse(domain, true);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteError(ex);
                    // A lot goes on in the try block, so this exception doesn't necessarily mean Paratext is inaccessible,
                    // so don't mark Paratext as uninitialized
                    return(false);
                }
                return(true);
            }
示例#28
0
 static void Main(string[] args)
 {
     var connectionString = "Host=localhost;Database=Test44;Username=postgres;Password=postgres";
     //var b = ImportDomain.TestConnection(connectionString);
     var rr = ImportDomain.GetRelations(connectionString);
 }
示例#29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Helper method to get a TextEnum ready to read
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private ISCTextEnum GetTextEnum(ImportDomain domain, BCVRef startRef, BCVRef endRef)
		{
			// Save settings before enumerating, which will get the styles hooked up in the mapping list
			m_settings.SaveSettings();

			SCScriptureText scText = new SCScriptureText(m_settings, domain);
			return scText.TextEnum(startRef, endRef);
		}
示例#30
0
		/// <summary></summary>
		public DummySCScriptureText(ScrImportSet settings, ImportDomain domain):
			base(settings, domain)
		{
		}
示例#31
0
		/// <summary></summary>
		public DummySCTextEnum(IScrImportSet settings, ImportDomain domain,
			BCVRef startRef, BCVRef endRef) :
			base(settings, domain, startRef, endRef)
		{
			DynamicMock mockConverters = new DynamicMock(typeof(IEncConverters));
			mockConverters.SetupResultForParams("Item", new DummyEncConverter(), "UPPERCASE");
			m_encConverters = (IEncConverters)mockConverters.MockInstance;
		}
示例#32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Load the P6 vernacular project if it is specified and is to be included
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected bool LoadParatextVernacularProject()
		{
			if (m_settings.ParatextScrProj == null)
				return false;
			m_currentDomain = ImportDomain.Main;
			LoadParatextProject(m_settings.ParatextScrProj);
			return true;
		}
示例#33
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Load the P6 notes project if it is specified and is to be included
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected bool LoadParatextNotesProject()
		{
			if (m_settings.ParatextNotesProj == null || !m_settings.ImportAnnotations)
				return false;
			m_currentDomain = ImportDomain.Annotations;
			LoadParatextProject(m_settings.ParatextNotesProj);
			return true;
		}
示例#34
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets flag to indicate whether this mapping's begin marker is in use in the given
		/// import source -- Use this version only for non-Paratext 6.
		/// </summary>
		/// <param name="importDomain">Import domain of the source</param>
		/// <param name="icuLocale">ICU locale of the import source</param>
		/// <param name="noteType">The default note type for the import source</param>
		/// <param name="value"><c>true</c> if the marker is in use</param>
		/// ------------------------------------------------------------------------------------
		public void SetIsInUse(ImportDomain importDomain, string icuLocale,
			ICmAnnotationDefn noteType, bool value)
		{
			m_inUse[ScriptureServices.CreateImportSourceKey(importDomain, icuLocale, noteType)] = value;
		}
示例#35
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Sets flag to indicate whether this mapping's begin marker is in use in the given
 /// import source -- Use this version only for non-Paratext 6.
 /// </summary>
 /// <param name="importDomain">Import domain of the source</param>
 /// <param name="icuLocale">ICU locale of the import source</param>
 /// <param name="hvoNoteType">ID of the default note type for the import source</param>
 /// <param name="value"><c>true</c> if the marker is in use</param>
 /// ------------------------------------------------------------------------------------
 public void SetIsInUse(ImportDomain importDomain, string icuLocale, int hvoNoteType,
                        bool value)
 {
     m_inUse[ScrImportSet.CreateImportSourceKey(importDomain, icuLocale, hvoNoteType)] = value;
 }
示例#36
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style name
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string icuLocale, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
		{
			m_beginMarker = beginMarker;
			m_endMarker = endMarker;
			m_isExcluded = isExcluded;
			m_mappingTarget = mappingTarget;
			m_domain = domain;
			m_styleName = styleName;
			m_style = null;
			m_icuLocale = icuLocale;
			m_noteType = noteType;
			if (isInUse)
			{
				m_inUse[ScrImportSet.CreateImportSourceKey(importDomain, icuLocale,
					noteType == null ? 0 : noteType.Hvo)] = isInUse;
			}
		}
示例#37
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Construct a ScrImportFileInfo based on a Toolbox (i.e., non-Paratext 5) filename.
 /// This is used only in tests.
 /// </summary>
 /// <param name="fileName">Name of the file whose info this represents</param>
 /// <param name="mappingList">Sorted list of mappings to which newly found mappings
 /// should (and will) be added</param>
 /// <param name="domain">The import domain to which this file belongs</param>
 /// <param name="wsId">The writing system identifier of the source to which this file
 /// belongs (null for Scripture source)</param>
 /// <param name="noteType">The CmAnnotationDefn of the source to which
 /// this file belongs (only used for Note sources)</param>
 /// ------------------------------------------------------------------------------------
 internal ScrImportFileInfo(string fileName, ScrMappingList mappingList, ImportDomain domain,
                            string wsId, ICmAnnotationDefn noteType)
     : this(fileName, mappingList, domain, wsId, noteType, false)
 {
 }
示例#38
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get the file list for the given domain, writing system identifier and note type.
		/// </summary>
		/// <param name="domain">The source domain</param>
		/// <param name="wsId">The writing system identifier for the source (ignored for
		/// scripture domain)</param>
		/// <param name="noteType">The CmAnnotationDefn for the note type (ignored for back
		/// trans and scripture domains)</param>
		/// <param name="createListIfNeeded">True to create the list if it does not already
		/// exist for a given writing system identifier and note type</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private ScrSfFileList GetFileList(ImportDomain domain, string wsId,
			ICmAnnotationDefn noteType,	bool createListIfNeeded)
		{
			Debug.Assert(ImportTypeEnum == TypeOfImport.Other || ImportTypeEnum == TypeOfImport.Paratext5);

			if (wsId == null)
				wsId = string.Empty;
			switch (domain)
			{
				default:
				case ImportDomain.Main:
					return m_scrFileInfoList;

				case ImportDomain.BackTrans:
				{
					// Look for a back trans source with the given writing system identifier.
					ScrSfFileList btList = m_btFileInfoLists[wsId] as ScrSfFileList;
					if (btList == null && createListIfNeeded)
					{
						btList = new ScrSfFileList(m_resolver);
						m_btFileInfoLists[wsId] = btList;
					}
					return btList;
				}
				case ImportDomain.Annotations:
				{
					// Look for a annotations source with the given writing system identifier.
					string key = ScriptureServices.CreateImportSourceKey(wsId, noteType);
					ScrSfFileList noteList = m_notesFileInfoLists[key] as ScrSfFileList;
					if (noteList == null && createListIfNeeded)
					{
						noteList = new ScrSfFileList(m_resolver);
						m_notesFileInfoLists[key] = noteList;
					}
					return noteList;
				}
			}
		}
示例#39
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets an import file source that will provide all of the files for an import
		/// </summary>
		/// <param name="domain"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public ImportFileSource GetImportFiles(ImportDomain domain)
		{
			lock (SyncRoot)
			{
				switch (domain)
				{
					case ImportDomain.Main:
						return new ImportFileSource(m_scrFileInfoList);
					case ImportDomain.BackTrans:
						return new ImportFileSource(m_btFileInfoLists, m_cache);
					case ImportDomain.Annotations:
						return new ImportFileSource(m_notesFileInfoLists, m_cache);
					default:
						throw new ArgumentException("unexpected domain");
				}
			}
		}
示例#40
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Remove a file from the file list
		/// </summary>
		/// <param name="fileName"></param>
		/// <param name="domain">The domain to remove the file from</param>
		/// <param name="wsId">The writing system identifier for the source (ignored for
		/// scripture domain)</param>
		/// <param name="noteType">The CmAnnotationDefn for the note type (ignored for back
		/// trans and scripture domains)</param>
		/// ------------------------------------------------------------------------------------
		public void RemoveFile(string fileName, ImportDomain domain, string wsId,
			ICmAnnotationDefn noteType)
		{
			lock (SyncRoot)
			{
				ScrSfFileList fileList = GetFileList(domain, wsId, noteType, false);
				if (fileList == null)
					return;

				foreach (IScrImportFileInfo info in fileList)
				{
					if (info.FileName.ToUpper() == fileName.ToUpper())
					{
						fileList.Remove(info);
						if (fileList.Count == 0)
						{
							GetMappingListForDomain(domain).ResetInUseFlags(domain, wsId, noteType);
						}
						return;
					}
				}
			}
		}
示例#41
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Add a default mapping for the given Standard Format marker if it does not exist yet.
 /// </summary>
 /// <param name="marker">The SF marker</param>
 /// <param name="domain">The import domain from which this marker originates</param>
 /// <param name="fAutoMapBtMarkers">Indicates whether markers beginning with "bt" should
 /// be treated as back-translation markers if possible.</param>
 /// <returns>The newly added mapping info, or the existing one if already in the list
 /// </returns>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo AddDefaultMappingIfNeeded(string marker, ImportDomain domain,
                                                    bool fAutoMapBtMarkers)
 {
     return(AddDefaultMappingIfNeeded(marker, null, domain, fAutoMapBtMarkers, true));
 }
示例#42
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a mocked <see cref="IScrImportFileInfo"/>. This is used to build an
		/// in-memory list of files.
		/// </summary>
		/// <param name="fileName">Name of the file whose info this represents</param>
		/// <param name="mappingList">Sorted list of mappings to which newly found mappings
		/// should (and will) be added</param>
		/// <param name="domain">The import domain to which this file belongs</param>
		/// <param name="wsId">The writing system identifier of the source to which this file
		/// belongs (null for Scripture source)</param>
		/// <param name="noteType">The CmAnnotationDefn of the source to which
		/// this file belongs (only used for Note sources)</param>
		/// <param name="scanInlineBackslashMarkers"><c>true</c> to look for backslash markers
		/// in the middle of lines. (Toolbox dictates that fields tagged with backslash markers
		/// must start on a new line, but Paratext considers all backslashes in the data to be
		/// SF markers.)</param>
		/// ------------------------------------------------------------------------------------
		public override IScrImportFileInfo Create(string fileName, ScrMappingList mappingList,
			ImportDomain domain, string wsId, ICmAnnotationDefn noteType, bool scanInlineBackslashMarkers)
		{
			IScrImportFileInfo info = MockRepository.GenerateStub<IScrImportFileInfo>();
			m_mockedScrImportFinfos[fileName] = info;
			info.Stub(x => x.FileName).Return(fileName);
			info.Stub(x => x.WsId).Return(wsId);
			info.Stub(x => x.NoteType).Return(noteType);
			return info;
		}
示例#43
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);
        }
示例#44
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle the start of book segments
		/// </summary>
		/// <returns><c>true if this segment was a book marker</c></returns>
		/// ------------------------------------------------------------------------------------
		private bool HandleStartOfBook()
		{
			// Start of Book (or possibly just another file with more of the same book)
			if (m_context != ContextValues.Book)
				return false;

			int wsCurrentStream = SOWrapper.CurrentWs(m_wsOfPrevImportStream);
			// If this is the first book, a new book, or a new domain...
			if (!m_fFoundABook || m_nBookNumber != SOWrapper.SegmentFirstRef.Book ||
				m_prevImportDomain != m_importDomain ||	m_wsOfPrevImportStream != wsCurrentStream)
			{
				ProcessStartOfBook();
				m_nPrevBookNumber = m_nBookNumber;
				m_fFoundABook = true;
				if (m_prevImportDomain != m_importDomain)
				{
					// if we are starting a new domain, remove "rogue" import style proxies that have
					// not been used.
					foreach (string marker in m_unmappedMarkers)
						if (m_styleProxies[marker].Style == null)
							m_styleProxies.Remove(marker);
					m_unmappedMarkers.Clear();
				}
			}
			m_prevImportDomain = m_importDomain;
			m_wsOfPrevImportStream = wsCurrentStream;
			if (m_importDomain == ImportDomain.BackTrans)
			{
				m_fBackTransChapterNumPending = m_fBackTransVerseNumPending = false;
			}
			return true;
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Sets flag to indicate whether this mapping's begin marker is in use in the given
 /// import source -- Use this version only for non-Paratext 6.
 /// </summary>
 /// <param name="importDomain">Import domain of the source</param>
 /// <param name="icuLocale">ICU locale of the import source</param>
 /// <param name="noteType">The default note type for the import source</param>
 /// <param name="value"><c>true</c> if the marker is in use</param>
 /// ------------------------------------------------------------------------------------
 public void SetIsInUse(ImportDomain importDomain, string icuLocale,
                        ICmAnnotationDefn noteType, bool value)
 {
     m_inUse[ScriptureServices.CreateImportSourceKey(importDomain, icuLocale, noteType)] = value;
 }
示例#46
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="SCScriptureText"/> class.
		/// </summary>
		/// <param name="settings">The import settings</param>
		/// <param name="domain">The source domain</param>
		/// ------------------------------------------------------------------------------------
		public SCScriptureText(IScrImportSet settings, ImportDomain domain)
		{
			Debug.Assert(settings != null);
			m_settings = settings;
			m_domain = domain;
		}
示例#47
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;
		}
示例#48
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);
        }
示例#49
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Load the P6 Back translation project if it is specified and is to be included
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected bool LoadParatextBackTranslationProject()
		{
			if (m_settings.ParatextBTProj == null ||
				!(m_settings.ImportBackTranslation || m_settings.ImportAnnotations))
				return false;
			m_currentDomain = ImportDomain.BackTrans;
			LoadParatextProject(m_settings.ParatextBTProj);
			return true;
		}
示例#50
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Make sure that the source contains the list of files given
		/// </summary>
		/// <param name="files"></param>
		/// <param name="domain"></param>
		/// ------------------------------------------------------------------------------------
		private void CheckFileListContents(string[] files, ImportDomain domain)
		{
			ImportFileSource source = m_importSettings.GetImportFiles(domain);
			bool[] found = new bool[files.Length];
			foreach (ScrImportFileInfo info in source)
			{
				bool foundFile = false;
				for (int index = 0; index < files.Length; index++)
				{
					if (info.FileName.ToUpper() == files[index].ToUpper())
					{
						Assert.IsFalse(found[index], "Found the " + domain + " file twice: " + files[index]);
						found[index] = foundFile = true;
						break;
					}
				}
				Assert.IsTrue(foundFile, "The file in " + domain + " domain was not found in the list of expected files: " + info.FileName);
			}
			for (int index = 0; index < found.Length; index++)
				Assert.IsTrue(found[index], "File not found in " + domain + " source: " + files[index]);
		}
示例#51
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Add a file to the project, and determine the file encoding and mappings.
		/// </summary>
		/// <param name="fileName">file name to add</param>
		/// <param name="domain">The domain to add the file to</param>
		/// <param name="wsId">The writing system identifier for the source (ignored for
		/// scripture domain)</param>
		/// <param name="noteType">The CmAnnotationDefn for the note type
		/// (ignored for back trans and scripture domains)</param>
		/// <param name="fileRemovedHandler">Handler for FileRemoved event (can be null if
		/// caller doesn't need to know if a file is removed as a result of a overlapping
		/// conflict</param>
		/// <returns>The IScrImportFileInfo representing the added file</returns>
		/// ------------------------------------------------------------------------------------
		public IScrImportFileInfo AddFile(string fileName, ImportDomain domain, string wsId,
			ICmAnnotationDefn noteType, ScrImportFileEventHandler fileRemovedHandler)
		{
			lock (SyncRoot)
			{
				if (ImportTypeEnum == TypeOfImport.Paratext6)
					throw new InvalidOperationException("Cannot add files to Paratext 6 import Projects");

				// first check to see if the file is already in the project,
				// if so - then remove the file.
				RemoveFile(fileName, domain, wsId, noteType);

				// Make a new file info entry for the added file
				IScrImportFileInfo info = m_scrImpFinfoFact.Create(fileName, GetMappingListForDomain(domain),
																   domain, wsId, noteType,
																   (ImportTypeEnum == TypeOfImport.Paratext5));

				ScrSfFileList fileList = GetFileList(domain, wsId, noteType, true);

				if (fileRemovedHandler != null)
					fileList.FileRemoved += fileRemovedHandler;

				int index;
				try
				{
					index = fileList.Add(info);
				}
				finally
				{
					if (fileRemovedHandler != null)
						fileList.FileRemoved -= fileRemovedHandler;
				}

				return (index == -1) ? null : info;
			}
		}
示例#52
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets flag to indicate whether this mapping's begin marker is in use in the given
		/// import source -- Use this version only for non-Paratext 6.
		/// </summary>
		/// <param name="importDomain">Import domain of the source</param>
		/// <param name="icuLocale">ICU locale of the import source</param>
		/// <param name="hvoNoteType">ID of the default note type for the import source</param>
		/// <param name="value"><c>true</c> if the marker is in use</param>
		/// ------------------------------------------------------------------------------------
		public void SetIsInUse(ImportDomain importDomain, string icuLocale, int hvoNoteType,
			bool value)
		{
			m_inUse[ScrImportSet.CreateImportSourceKey(importDomain, icuLocale, hvoNoteType)] = value;
		}
示例#53
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This is the actual workhorse to Import Scripture
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void Import()
		{
			DateTime beg = DateTime.Now;
			// make sure we don't try to listen to all the changes we are making to the
			// view during import.
			using (new IgnorePropChanged(m_cache, PropChangedHandling.SuppressChangeWatcher))
			{
				try
				{
					Initialize();
					m_fFoundABook = false;

					// Get and process each scripture segment
					string sText, sMarker;
					ImportDomain domain;
					try
					{
						while (SOWrapper.GetNextSegment(out sText, out sMarker, out domain))
						{
							//				Trace.WriteLine(sMarker + " " + sText);
							m_sSegmentText = sText;
							m_sMarker = sMarker;
							m_importDomain = domain;
							ProcessSegment();
						}
					}
					catch (EncodingConverterException e)
					{
						m_importCallbacks.ErrorMessage(e);
						StopImport();
					}

					// If no book was imported then tell the user that the books they specified didn't
					// import properly.
					if (!m_fFoundABook)
					{
						if (FwApp.App != null) // If we're not running the tests
						{
							string message = string.Format(TeResourceHelper.GetResourceString(
								"kstidImportNoBookError"),
								(m_settings as ScrImportSet).StartRef.AsString,
								(m_settings as ScrImportSet).EndRef.AsString);
							m_importCallbacks.ErrorMessage(message);
						}
						else
						{
							throw new ArgumentException("Found no book to import");
						}
					}

					FinalizeImport();
				}
				catch
				{
					try
					{
						FinalizeImport();
					}
					catch {}
					throw;
				}
				finally
				{
					m_importCallbacks.Position = m_importCallbacks.Maximum;
					if (SOWrapper != null)
						SOWrapper.Cleanup();
				}
			}
			System.Diagnostics.Debug.WriteLine("import time: " + (DateTime.Now - beg));
		}
示例#54
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get a MappingSet that is appropriate for the ImportDomain
		/// </summary>
		/// <param name="domain"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public MappingSet GetMappingSetForDomain(ImportDomain domain)
		{
			switch (domain)
			{
				default:
				case ImportDomain.Main:
				case ImportDomain.BackTrans:
					return MappingSet.Main;

				case ImportDomain.Annotations:
					return MappingSet.Notes;
			}
		}
示例#55
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Checks the contents of the project combo. We call this after we attempt to assign
		/// the projName in the import settings to the current selection in the project combo
		/// box.
		/// </summary>
		/// <param name="projName">Name of the project in the import settings.</param>
		/// <param name="projCombo">The project combo.</param>
		/// <param name="domain">The import domain.</param>
		/// ------------------------------------------------------------------------------------
		private void CheckProjectCombo(string projName, FwOverrideComboBox projCombo,
			ImportDomain domain)
		{
			string ptShortName = GetPTShortName(projCombo);

			// if the project name was set successfully to the contents of the short name from the combobox.
			if (projName != null && projName.Equals(ptShortName))
			{
				// no problems with the selected item. We're finished.
				return;
			}

			// If the project name is null but the selected project is "none" then the selected
			// item is fine. The selected project is "none" when the domain in back translation
			// or notes and the selected index in the combobox is 0.
			if ((domain == ImportDomain.BackTrans || domain == ImportDomain.Annotations) &&
				projCombo.SelectedIndex == 0)
			{
				return;
			}

			// However, if the project name is null and the selected item in the combo box
			// is something else, then we need to throw an exception so that the user will
			// be notified about a problem with the project that they selected.
			throw new ParatextLoadException(string.Format(TeResourceHelper.GetResourceString(
				"kstidParatextProjectLoadFailure"), ptShortName), null);
		}
示例#56
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets a mapping list based on the import domain
		/// </summary>
		/// <param name="domain">The import domain</param>
		/// <returns>The mapping list</returns>
		/// ------------------------------------------------------------------------------------
		public ScrMappingList GetMappingListForDomain(ImportDomain domain)
		{
			lock (SyncRoot)
				return GetMappingList(GetMappingSetForDomain(domain));
		}
示例#57
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Retrieves the ScrImportSource for the requested domain, WS, and note type
		/// </summary>
		/// <param name="domain">The source domain</param>
		/// <param name="wsId">The writing system identifier for the source (ignored for
		/// scripture domain)</param>
		/// <param name="noteTypeGuid">The GUID of the CmAnnotationDefn for the note type
		/// (ignored for back trans and scripture domains)</param>
		/// <param name="createSourceIfNeeded">True to create the source if it does not already
		/// exist for a given domain, writing system identifier and note type</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private IScrImportSource GetSource(ImportDomain domain, string wsId,
			Guid noteTypeGuid, bool createSourceIfNeeded)
		{
			switch (domain)
			{
				case ImportDomain.Main:
					return GetSourceForScripture(createSourceIfNeeded);

				case ImportDomain.BackTrans:
					return GetSourceForBT(wsId, createSourceIfNeeded);

				case ImportDomain.Annotations:
					{
						ICmAnnotationDefn noteType;
						try
						{
							noteType = Cache.ServiceLocator.GetInstance<ICmAnnotationDefnRepository>().GetObject(noteTypeGuid);
						}
						catch
						{
							noteType = null;
						}
						return GetSourceForNotes(wsId, noteType, createSourceIfNeeded);
					}

				default:
					throw new ArgumentException("unexpected domain");
			}
		}
示例#58
0
        public bool LoadProjectMappings(string project, ScrMappingList mappingList, ImportDomain domain)
        {
            // If the new project ID is null, then do not load mappings.
            if (project == null)
            {
                return(false);
            }

            // Load the tags from the paratext project and create mappings for them.
            ScrText scParatextText;

            try
            {
                // REVIEW (EberhardB): I'm not sure if ScrTextCollection.Get() returns a
                // reference to a ScrText or a new object (in which case we would have to
                // call Dispose() on it)
                scParatextText = ScrTextCollection.Get(project);
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex);
                return(false);
            }

            mappingList.ResetInUseFlags(domain);
            try
            {
                foreach (ScrTag tag in scParatextText.DefaultStylesheet.Tags)
                {
                    if (tag == null)
                    {
                        break;
                    }
                    string marker    = @"\" + tag.Marker;
                    string endMarker = string.Empty;
                    if (!String.IsNullOrEmpty(tag.Endmarker))
                    {
                        endMarker = @"\" + tag.Endmarker;
                    }

                    // When the nth marker has an end marker, the nth + 1 marker will be
                    // that end marker. Therefore, we have to skip those "end style" markers.
                    if (tag.StyleType == ScrStyleType.scEndStyle)
                    {
                        continue;
                    }

                    // Create a new mapping for this marker.
                    mappingList.AddDefaultMappingIfNeeded(marker, endMarker, domain, false, false);
                }
                ScrParser parser = scParatextText.Parser();
                foreach (int bookNum in scParatextText.BooksPresentSet.SelectedBookNumbers())
                {
                    foreach (UsfmToken token in parser.GetUsfmTokens(new VerseRef(bookNum, 0, 0), false, true))
                    {
                        if (token.Marker == null)
                        {
                            continue;                             // Tokens alternate between text and marker types
                        }
                        ImportMappingInfo mapping = mappingList[@"\" + token.Marker];
                        if (mapping != null)
                        {
                            mapping.SetIsInUse(domain, true);
                        }

                        // ENHANCE (TE-4408): Consider Detecting markers that occur in the data but are missing
                        // from the STY file. How can we write a test for this?
                        //else if (ScrImportFileInfo.IsValidMarker(sMarker))
                        //{
                        //    mappingList.AddDefaultMappingIfNeeded(sMarker,domain, false, true);
                        //}
                        //else
                        //{
                        //    throw new ScriptureUtilsException(SUE_ErrorCode.InvalidCharacterInMarker, null, 0,
                        //        sMarker + sText, new ScrReference(scParatextTextSegment.FirstReference.BBCCCVVV));
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex);
                return(false);
            }
            return(true);
        }
示例#59
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Add a file to the project, and determine the file encoding and mappings.
		/// </summary>
		/// <param name="fileName">file name to add</param>
		/// <param name="domain">The domain to add the file to</param>
		/// <param name="wsId">The icu locale for the source (ignored for scripture domain)
		/// </param>
		/// <param name="noteType">The CmAnnotationDefn for the note type (ignored for back
		/// trans and scripture domains)</param>
		/// <returns>The IScrImportFileInfo representing the added file</returns>
		/// ------------------------------------------------------------------------------------
		public IScrImportFileInfo AddFile(string fileName, ImportDomain domain, string wsId,
			ICmAnnotationDefn noteType)
		{
			return AddFile(fileName, domain, wsId, noteType, null);
		}
示例#60
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style name
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string icuLocale, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
 {
     m_beginMarker   = beginMarker;
     m_endMarker     = endMarker;
     m_isExcluded    = isExcluded;
     m_mappingTarget = mappingTarget;
     m_domain        = domain;
     m_styleName     = styleName;
     m_style         = null;
     m_icuLocale     = icuLocale;
     m_noteType      = noteType;
     if (isInUse)
     {
         m_inUse[ScrImportSet.CreateImportSourceKey(importDomain, icuLocale,
                                                    noteType == null ? 0 : noteType.Hvo)] = isInUse;
     }
 }