コード例 #1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:UndoImportOverriddenBookAction"/>
		/// class.
		/// </summary>
		/// <param name="manager">A class that manages undoable aspects of importing and holds
		/// the state info needed for importing and later undoing the import.</param>
		/// <param name="existingBook">The existing book.</param>
		/// <remarks>This is internal because we only want UndoImportManager to create these
		/// </remarks>
		/// ------------------------------------------------------------------------------------
		internal UndoImportModifiedBookAction(UndoImportManager manager, IScrBook existingBook)
			: base()
		{
			m_manager = manager;
			m_canonicalBookNum = existingBook.CanonicalNum;
			m_manager.ScriptureObj.AddBookToSavedVersion(manager.BackupVersion, existingBook);
		}
コード例 #2
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:UndoImportOverriddenBookAction"/>
 /// class.
 /// </summary>
 /// <param name="manager">A class that manages undoable aspects of importing and holds
 /// the state info needed for importing and later undoing the import.</param>
 /// <param name="existingBook">The existing book.</param>
 /// <remarks>This is internal because we only want UndoImportManager to create these
 /// </remarks>
 /// ------------------------------------------------------------------------------------
 internal UndoImportModifiedBookAction(UndoImportManager manager, IScrBook existingBook)
     : base()
 {
     m_manager          = manager;
     m_canonicalBookNum = existingBook.CanonicalNum;
     m_manager.ScriptureObj.AddBookToSavedVersion(manager.BackupVersion, existingBook);
 }
コード例 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Imports using the specified import settings.
        /// </summary>
        /// <param name="progressDlg">The progress dialog.</param>
        /// <param name="parameters">The paramaters: import settings, undo action, and book
        /// merger, TeImportUi.</param>
        /// <returns>The Scripture reference of the first thing imported</returns>
        /// <remarks>This method runs on the background thread!</remarks>
        /// ------------------------------------------------------------------------------------
        protected virtual object ImportSf(IAdvInd4 progressDlg, object[] parameters)
        {
            Debug.Assert(parameters.Length == 3);
            IScrImportSet     importSettings = (IScrImportSet)parameters[0];
            UndoImportManager undoManager    = (UndoImportManager)parameters[1];
            TeImportUi        importUi       = (TeImportUi)parameters[2];

            return(TeSfmImporter.Import(importSettings, m_cache, m_styleSheet,
                                        undoManager, importUi));
        }
コード例 #4
0
        /// <summary>
        /// Calls the importer.
        /// </summary>
        /// <param name="importSettings">The import settings.</param>
        /// <param name="undoManager">The undo manager.</param>
        /// <param name="importUi">The import UI.</param>
        /// <returns></returns>
        protected virtual ScrReference Import(IScrImportSet importSettings, UndoImportManager undoManager,
                                              TeImportUi importUi)
        {
            if (importSettings != null)
            {
                return(TeSfmImporter.Import(importSettings, m_cache, m_styleSheet,
                                            undoManager, importUi, m_fParatextStreamlinedImport));
            }

            return((ScrReference)TeXmlImporter.Import(m_cache, m_styleSheet, m_sOXESFile,
                                                      undoManager, importUi));
        }
コード例 #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Import scripture and embed it in a Undo task so that it is undoable.
        /// Nb: this creates a Mark in the undo stack (unless no books at all are imported or an
        /// error occurs), which is designed to be 'collapsed' to after all books in the batch
        /// are imported, so we get a single Undo task for the whole Import in the end. Code
        /// (such as tests) that calls this directly should call
        /// UndoManager.CollapseAllUndoActions().
        /// </summary>
        /// <param name="importSettings">The SFM import settings.  If null, then this is an XML import.</param>
        /// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog,
        /// <c>false</c> to run without UI.</param>
        /// <param name="updateDescription">description of the data update being done (i.e.,
        /// which type of import).</param>
        /// <returns>The reference of the first thing that was imported</returns>
        /// ------------------------------------------------------------------------------------
        protected ScrReference ImportWithUndoTask(IScrImportSet importSettings,
                                                  bool fDisplayUi, string updateDescription)
        {
            m_undoImportManager = new UndoImportManager(m_cache);
            if (m_mainWnd == null)
            {
                // Can happen in tests (and is probably the only time we'll get here).
                return(InternalImport(importSettings, fDisplayUi));
            }

            using (new DataUpdateMonitor(m_mainWnd, updateDescription))
            {
                return(InternalImport(importSettings, fDisplayUi));
            }
        }
コード例 #6
0
ファイル: TeImport.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the TeSfmImporter class
		/// </summary>
		/// <param name="settings">Import settings object (filled in by wizard)</param>
		/// <param name="cache">The cache used to import to and get misc. info. from.</param>
		/// <param name="styleSheet">Stylesheet from which to get scripture styles.</param>
		/// <param name="undoManager">The undo import manager(which is responsible for creating
		/// and maintainging the archive of original books being overwritten).</param>
		/// <param name="importCallbacks">UI callbacks</param>
		/// ------------------------------------------------------------------------------------
		protected TeSfmImporter(IScrImportSet settings, FdoCache cache,
			FwStyleSheet styleSheet, UndoImportManager undoManager, TeImportUi importCallbacks)
		{
			Debug.Assert(cache != null);
			Debug.Assert(styleSheet != null);

			m_settings = settings;
			m_cache = cache;
			m_styleSheet = styleSheet;
			m_undoManager = undoManager;
			m_importCallbacks = importCallbacks;
			m_importCallbacks.Importer = this;

			Debug.Assert(m_settings.BasicSettingsExist);
			// ENHANCE (TomB): Make it possible to start importing in the middle
			// of a book.
			(m_settings as ScrImportSet).StartRef =
				new BCVRef((m_settings as ScrImportSet).StartRef.Book, 1, 0);
		}
コード例 #7
0
ファイル: TeImport.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Call this static method to Import Scripture
		/// </summary>
		/// <param name="settings">Import settings object (filled in by wizard)</param>
		/// <param name="cache">The cache used to import to and get misc. info. from.</param>
		/// <param name="styleSheet">Stylesheet from which to get scripture styles.</param>
		/// <param name="undoManager">The undo import manager (which is responsible for creating
		/// and maintaining the archive of original books being overwritten and maintaining
		/// the book filter).</param>
		/// <param name="importCallbacks">UI callbacks</param>
		/// <returns>
		/// The Scripture reference of the first thing that was imported
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static ScrReference Import(IScrImportSet settings, FdoCache cache,
			FwStyleSheet styleSheet, UndoImportManager undoManager, TeImportUi importCallbacks)
		{
			using (TeSfmImporter importer = new TeSfmImporter(settings, cache, styleSheet, undoManager,
				importCallbacks))
			{
				importer.Import();
				return importer.m_firstImportedRef;
			}	// Dispose() releases any hold on ICU character properties.
		}
コード例 #8
0
ファイル: TeImport.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This static method imports Scripture (This overload used only for testing w/o merge
		/// or overwrite dialog.)
		/// </summary>
		/// <param name="settings">Import settings object (filled in by wizard)</param>
		/// <param name="cache">The cache used to import to and get misc. info. from.</param>
		/// <param name="styleSheet">Stylesheet from which to get scripture styles.</param>
		/// <param name="undoManager">The undo import manager (which is responsible for creating
		/// and maintaining the archive of original books being overwritten and maintaining
		/// the book filter).</param>
		/// <returns>The reference of the first thing that was imported</returns>
		/// ------------------------------------------------------------------------------------
		public static ScrReference Import(IScrImportSet settings, FdoCache cache,
			FwStyleSheet styleSheet, UndoImportManager undoManager)
		{
			return Import(settings, cache, styleSheet, undoManager, null);
		}
コード例 #9
0
ファイル: TeImport.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected virtual void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (m_isDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_ParaBldr != null)
					m_ParaBldr.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_ParaBldr = null;
			m_cache = null;
			m_styleSheet = null;
			m_scr = null;
			m_undoManager = null;
			m_importCallbacks = null;
			m_ScrSectionHeadParaProxy = null;
			m_DefaultIntroSectionHeadParaProxy = null;
			m_DefaultScrParaProxy = null;
			m_DefaultIntroParaProxy = null;
			m_BTStrBldrs = null;
			m_SavedParaBldr = null;
			m_CurrFootnote = null;
			m_ttpChapterNumber = null;
			m_sPrevBook = null;
			m_scrBook = null;
			m_currSection = null;

			m_isDisposed = true;
		}
コード例 #10
0
		/// <summary>
		/// Calls the importer.
		/// </summary>
		/// <param name="importSettings">The import settings.</param>
		/// <param name="undoManager">The undo manager.</param>
		/// <param name="importUi">The import UI.</param>
		/// <returns></returns>
		protected virtual ScrReference Import(IScrImportSet importSettings, UndoImportManager undoManager,
			TeImportUi importUi)
		{
			if (importSettings != null)
			{
				return TeSfmImporter.Import(importSettings, m_cache, m_styleSheet,
					undoManager, importUi, m_fParatextStreamlinedImport);
			}

			return (ScrReference) TeXmlImporter.Import(m_cache, m_styleSheet, m_sOXESFile,
				undoManager, importUi);
		}
コード例 #11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Import scripture and embed it in a Undo task so that it is undoable.
		/// Nb: this creates a Mark in the undo stack (unless no books at all are imported or an
		/// error occurs), which is designed to be 'collapsed' to after all books in the batch
		/// are imported, so we get a single Undo task for the whole Import in the end. Code
		/// (such as tests) that calls this directly should call
		/// UndoManager.CollapseAllUndoActions().
		/// </summary>
		/// <param name="importSettings">The SFM import settings.  If null, then this is an XML import.</param>
		/// <param name="fDisplayUi">set to <c>true</c> to display the progress dialog,
		/// <c>false</c> to run without UI.</param>
		/// <param name="updateDescription">description of the data update being done (i.e.,
		/// which type of import).</param>
		/// <returns>The reference of the first thing that was imported</returns>
		/// ------------------------------------------------------------------------------------
		protected ScrReference ImportWithUndoTask(IScrImportSet importSettings,
			bool fDisplayUi, string updateDescription)
		{
			m_undoImportManager = new UndoImportManager(m_cache);
			if (m_mainWnd == null)
			{
				// Can happen in tests (and is probably the only time we'll get here).
				return InternalImport(importSettings, fDisplayUi);
			}

			using (new DataUpdateMonitor(m_mainWnd, updateDescription))
			{
				return InternalImport(importSettings, fDisplayUi);
			}
		}
コード例 #12
0
ファイル: TeImport.cs プロジェクト: sillsdev/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Call this static method to Import Scripture
		/// </summary>
		/// <param name="settings">Import settings object (filled in by wizard)</param>
		/// <param name="cache">The cache used to import to and get misc. info. from.</param>
		/// <param name="styleSheet">Stylesheet from which to get scripture styles.</param>
		/// <param name="undoManager">The undo import manager (which is responsible for creating
		/// and maintaining the archive of original books being overwritten and maintaining
		/// the book filter).</param>
		/// <param name="importCallbacks">UI callbacks</param>
		/// <param name="streamLinedImport">flag indicated if import id done through FLEx.</param>
		/// <returns>
		/// The Scripture reference of the first thing that was imported
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static ScrReference Import(IScrImportSet settings, FdoCache cache,
			FwStyleSheet styleSheet, UndoImportManager undoManager, TeImportUi importCallbacks,
			bool streamLinedImport = false)
		{
			using (TeSfmImporter importer = new TeSfmImporter(settings, cache, styleSheet, undoManager,
				importCallbacks, streamLinedImport))
			{
				importer.Import();
				importCallbacks.AllowCancel = false; // LT-16647: Disallow canceling import after it is complete (before disposing importer).
				return importer.m_firstImportedRef;
			}	// Dispose() releases any hold on ICU character properties.
		}
コード例 #13
0
ファイル: TeXmlImport.cs プロジェクト: sillsdev/WorldPad
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Call this static method to import Scripture from an OXES (XML) file.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="styleSheet"></param>
		/// <param name="sOXESFile"></param>
		/// <param name="undoManager"></param>
		/// <param name="importUi"></param>
		/// <returns></returns>
		/// -----------------------------------------------------------------------------------
		public static object Import(FdoCache cache, FwStyleSheet styleSheet, string sOXESFile,
			UndoImportManager undoManager, TeImportUi importUi)
		{
#if DEBUG
			DateTime start = DateTime.Now;
#endif
			using (TeXmlImporter importer = new TeXmlImporter(cache, styleSheet, sOXESFile, undoManager,
				importUi))
			{
				importer.ImportXml();
#if DEBUG
				TimeSpan span = new TimeSpan(DateTime.Now.Ticks - start.Ticks);
				string msg = String.Format("Time to import {0}: {1} hours, {2} minutes, {3} seconds, {4} millseconds ({5} ticks).",
					sOXESFile, span.Hours, span.Minutes, span.Seconds, span.Milliseconds, span.Ticks);
				Debug.WriteLine(msg);
#endif
				return importer.m_firstImportedRef;
			}
		}
コード例 #14
0
ファイル: TeXmlImport.cs プロジェクト: sillsdev/WorldPad
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Constructor used with XML (OXES) based import.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="styleSheet"></param>
		/// <param name="sOXESFile">name of the XML (OXES) file</param>
		/// <param name="undoManager"></param>
		/// <param name="importCallbacks"></param>
		/// -----------------------------------------------------------------------------------
		private TeXmlImporter(FdoCache cache, FwStyleSheet styleSheet, string sOXESFile,
			UndoImportManager undoManager, TeImportUi importCallbacks)
		{
			Debug.Assert(cache != null);
			Debug.Assert(styleSheet != null);
			Debug.Assert(sOXESFile != null && sOXESFile.Length > 0);

			m_cache = cache;
			m_styleSheet = styleSheet;
			m_sOXESFile = sOXESFile;

			// Allow tests to pass in a bogus filename.
			m_sOXESDir = (m_sOXESFile.Trim().Length > 0 ? Path.GetDirectoryName(m_sOXESFile) : null);
			m_undoManager = undoManager;
			m_importCallbacks = importCallbacks;
			m_importCallbacks.Importer = this;
			int cChapters = CountChapters();
			if (cChapters > 0)
				m_importCallbacks.Maximum = cChapters;
			m_rfcWs = new RfcWritingSystem(cache, false);
		}
コード例 #15
0
ファイル: TeXmlImport.cs プロジェクト: bbriggs/FieldWorks
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Constructor used with XML (OXES) based import.
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="styleSheet"></param>
		/// <param name="sOXESFile">name of the XML (OXES) file</param>
		/// <param name="undoManager"></param>
		/// <param name="importCallbacks"></param>
		/// -----------------------------------------------------------------------------------
		protected TeXmlImporter(FdoCache cache, FwStyleSheet styleSheet, string sOXESFile,
			UndoImportManager undoManager, TeImportUi importCallbacks)
		{
			Debug.Assert(cache != null);
			Debug.Assert(styleSheet != null);
			Debug.Assert(sOXESFile != null && sOXESFile.Length > 0);

			m_cache = cache;
			m_styleSheet = styleSheet;
			m_sOXESFile = sOXESFile;

			// Allow tests to pass in a bogus filename.
			m_sOXESDir = (m_sOXESFile.Trim().Length > 0 ? Path.GetDirectoryName(m_sOXESFile) : null);
			m_undoManager = undoManager;
			m_importCallbacks = importCallbacks;
			m_importCallbacks.Importer = this;
			int cChapters = CountChapters();
			if (cChapters > 0)
				m_importCallbacks.Maximum = cChapters;

			m_tssChapterStartKey = TsStringUtils.MakeTss("chapterStart", m_cache.DefaultUserWs);
			m_tssVerseStartKey = TsStringUtils.MakeTss("verseStart", m_cache.DefaultUserWs);
			m_tssLabelTrKey = TsStringUtils.MakeTss("labelTr", m_cache.DefaultUserWs);
			m_tssNoteKey = TsStringUtils.MakeTss("note", m_cache.DefaultUserWs);
			m_tssFigureKey = TsStringUtils.MakeTss("figure", m_cache.DefaultUserWs);
		}