public void UndoImportNoRedo() { CheckDisposed(); // Need to have an IP m_firstDraftView.RootBox.MakeSimpleSel(true, true, false, true); // When we start up we shouldn't be able to Undo Assert.IsFalse(m_firstMainWnd.Cache.CanUndo, "Undo possible after startup"); // set up a ScrImportSet for our test ScrImportSet settings = new ScrImportSet(); m_firstMainWnd.Cache.LangProject.TranslatedScriptureOA.DefaultImportSettings = settings; ImportTests.MakeParatextImportTestSettings(settings); // do the import settings.StartRef = settings.EndRef = new BCVRef(63, 1, 1); m_firstMainWnd.ImportWithUndoTask(settings); Assert.IsTrue(m_firstMainWnd.Cache.CanUndo, "Undo not possible after import"); m_firstMainWnd.SimulateEditUndoClick(); Assert.IsFalse(m_firstMainWnd.Cache.CanUndo, "Import not undone"); // make sure that REDO is not enabled. Assert.IsFalse(m_firstMainWnd.Cache.CanRedo, "Import redo should not be enabled"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor to use when using an in-memory cache /// </summary> /// <param name="settings">Import settings</param> /// <param name="cache">FDO Cache</param> /// <param name="styleSheet">A stylesheet</param> /// <param name="inMemoryCache"> in-memory cache (use null to test against real DB)</param> /// ------------------------------------------------------------------------------------ public DummyTeImporter(ScrImportSet settings, FdoCache cache, FwStyleSheet styleSheet, ScrInMemoryFdoCache inMemoryCache) : base(settings, cache, styleSheet, new DummyUndoImportManager(inMemoryCache), new TeImportNoUi()) { m_inMemoryCache = inMemoryCache; }
public void LoadParatext5Project() { CheckDisposed(); ScrObjWrapper wrapper = new ScrObjWrapper(); ScrImportSet settings = new ScrImportSet(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(settings); settings.ImportTypeEnum = TypeOfImport.Paratext5; settings.StartRef = new BCVRef(1, 1, 1); settings.EndRef = new BCVRef(66, 22, 21); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFile("EXO", new string[] {@"\mt Exodus", @"\c 1", @"\v 1 This is fun!"}); settings.AddFile(fileName, ImportDomain.Main, null, 0); wrapper.LoadScriptureProject(settings); Assert.IsFalse(wrapper.BooksPresent.Contains(1)); Assert.IsTrue(wrapper.BooksPresent.Contains(2)); string sText, sMarker; ImportDomain domain; Assert.IsTrue(wrapper.GetNextSegment(out sText, out sMarker, out domain)); Assert.AreEqual(fileName, wrapper.CurrentFileName); Assert.AreEqual(1, wrapper.CurrentLineNumber); Assert.AreEqual(new BCVRef(2, 1, 0), wrapper.SegmentFirstRef); Assert.AreEqual(new BCVRef(2, 1, 0), wrapper.SegmentLastRef); Assert.AreEqual(2, wrapper.ExternalPictureFolders.Count); Assert.AreEqual(Cache.LangProject.ExternalLinkRootDir, wrapper.ExternalPictureFolders[0]); Assert.AreEqual(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), wrapper.ExternalPictureFolders[1]); } }
public void LoadParatext5Project() { CheckDisposed(); ScrObjWrapper wrapper = new ScrObjWrapper(); ScrImportSet settings = new ScrImportSet(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(settings); settings.ImportTypeEnum = TypeOfImport.Paratext5; settings.StartRef = new BCVRef(1, 1, 1); settings.EndRef = new BCVRef(66, 22, 21); using (TempSFFileMaker fileMaker = new TempSFFileMaker()) { string fileName = fileMaker.CreateFile("EXO", new string[] { @"\mt Exodus", @"\c 1", @"\v 1 This is fun!" }); settings.AddFile(fileName, ImportDomain.Main, null, 0); wrapper.LoadScriptureProject(settings); Assert.IsFalse(wrapper.BooksPresent.Contains(1)); Assert.IsTrue(wrapper.BooksPresent.Contains(2)); string sText, sMarker; ImportDomain domain; Assert.IsTrue(wrapper.GetNextSegment(out sText, out sMarker, out domain)); Assert.AreEqual(fileName, wrapper.CurrentFileName); Assert.AreEqual(1, wrapper.CurrentLineNumber); Assert.AreEqual(new BCVRef(2, 1, 0), wrapper.SegmentFirstRef); Assert.AreEqual(new BCVRef(2, 1, 0), wrapper.SegmentLastRef); Assert.AreEqual(2, wrapper.ExternalPictureFolders.Count); Assert.AreEqual(Cache.LangProject.ExternalLinkRootDir, wrapper.ExternalPictureFolders[0]); Assert.AreEqual(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), wrapper.ExternalPictureFolders[1]); } }
/// ------------------------------------------------------------------------------------ /// <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 override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_dlg != null) { m_dlg.Dispose(); } if (m_regData != null) { m_regData.RestoreRegistryData(); } Unpacker.RemoveParatextTestProjects(); } // Dispose unmanaged resources here, whether disposing is true or false. m_dlg = null; m_regData = null; m_settings = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <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 override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_importer != null) { m_importer.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_styleSheet = null; // FwStyleSheet should implement IDisposable. m_settings = null; m_importer = null; // TeImporter should implement IDisposable. if (m_ttpVernWS != null) { // Marshal.ReleaseComObject(m_ttpVernWS); m_ttpVernWS = null; } if (m_ttpAnalWS != null) { // Marshal.ReleaseComObject(m_ttpAnalWS); m_ttpAnalWS = null; } base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates test data for a Paratext 6 import. /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_scrInMemoryCache.InitializeScripture(); m_scrInMemoryCache.InitializeAnnotationDefs(); m_settings = new ScrImportSet(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = TypeOfImport.Paratext6; m_settings.ParatextScrProj = "TEV"; }
public override void Exit() { CheckDisposed(); m_importer.Dispose(); m_importer = null; m_styleSheet = null; m_settings = null; base.Exit(); }
public override void Exit() { CheckDisposed(); m_builder.Dispose(); m_builder = null; m_settings = null; m_mappingList = null; base.Exit(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates test data and initializes the DummySFFileListBuilder so we can test it. /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_scrInMemoryCache.InitializeScripture(); m_scrInMemoryCache.InitializeAnnotationDefs(); m_settings = new ScrImportSet(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = TypeOfImport.Other; m_builder = new DummySFFileListBuilder(); m_builder.ImportSettings = m_settings; DummyScrImportFileInfo.s_alwaysPretendFileDoesNotExist = false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Iterate through the ScriptureTexts' lists of tags. If any missing mappings are found /// return true to give the user a chance to use the ImportWizard to map everything. /// </summary> /// <param name="settings">Import settings object</param> /// <returns><c>true</c> if the settings represent a P6 project which has markers (tags) /// in its stylesheet which the user has not had a chance to map in the import wizard. /// </returns> /// ------------------------------------------------------------------------------------ protected bool ParatextProjHasUnmappedMarkers(ScrImportSet settings) { // Load ScriptureText object if (settings.ImportTypeEnum != TypeOfImport.Paratext6) { return(false); } return(ParatextProjHasUnmappedMarkers(settings.ParatextScrProj) || ParatextProjHasUnmappedMarkers(settings.ParatextBTProj) || ParatextProjHasUnmappedMarkers(settings.ParatextNotesProj)); }
public override void Exit() { CheckDisposed(); try { m_dlg.Close(); m_dlg = null; m_settings = null; } finally { base.Exit(); } }
public void Init() { CheckDisposed(); m_builder = new DummySFFileListBuilder(); m_cache = FdoCache.Create("TestLangProj"); if (!m_cache.DatabaseAccessor.IsTransactionOpen()) { m_cache.DatabaseAccessor.BeginTrans(); } m_cache.BeginUndoTask("Undo SfFileListBuilderTest", "Redo SfFileListBuilderTest"); m_settings = new ScrImportSet(); m_cache.LangProject.TranslatedScriptureOA.DefaultImportSettings = m_settings; }
///------------------------------------------------------------------------------- /// <summary> /// When the Source button is clicked, display the import wizard. /// </summary> ///------------------------------------------------------------------------------- private void btnSource_Click(object sender, System.EventArgs e) { ILangProject lp = m_cache.LangProject; Scripture scr = (Scripture)lp.TranslatedScriptureOA; using (ImportWizard importWizard = new ImportWizard(lp.Name.AnalysisDefaultWritingSystem, scr, m_StyleSheet, m_cache, m_helpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { // Ditch any in-memory changes made to the settings. Reload from the DB. m_importSettings.RevertToSaved(); } // If there are no files after showing the wizard, close the import dialog if (InitBookNameList() == 0) { MessageBox.Show(this, DlgResources.ResourceString("kstidImportFilesUnavailable"), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); return; } // Update the file ranges for import because they may have changed. The default // set of settings may also have changed, so we re-retrieve them from the DB. m_importSettings = (ScrImportSet)scr.DefaultImportSettings; scrPsgFrom.Initialize(new ScrReference(StartRef, scr.Versification), scr, m_importSettings.BooksForProject.ToArray()); scrPsgTo.Initialize(new ScrReference(EndRef, scr.Versification), scr, m_importSettings.BooksForProject.ToArray()); // Update the passage controls to reflect the new range of files available // Only make changes that do not expand the available range of books since a // range may have been specified before the wizard was run that we do not // want to overwrite if (!scrPsgFrom.IsReferenceValid(scrPsgFrom.ScReference)) { SetStartRefToFirstImportableBook(); } if (!scrPsgTo.IsReferenceValid(scrPsgTo.ScReference)) { SetEndRefToLastImportableBook(); } } btnOK.Focus(); }
///------------------------------------------------------------------------------- /// <summary> /// Constructor for import dialog, requiring a language project. /// Use this constructor at run time. /// </summary> ///------------------------------------------------------------------------------- public ImportDialog(FwStyleSheet styleSheet, FdoCache cache, ScrImportSet settings, string helpFile) : this() { m_StyleSheet = styleSheet; m_cache = cache; Scripture scr = (Scripture)cache.LangProject.TranslatedScriptureOA; m_importSettings = settings; m_helpFile = helpFile; //InitBookNameList(); // Set the initial values for the controls from the static variables. radImportEntire.Checked = ImportEntire; radImportRange.Checked = !ImportEntire; chkTranslation.Checked = ImportTranslation; chkBackTranslation.Checked = ImportBackTranslation; chkBookIntros.Checked = ImportBookIntros; chkOther.Checked = ImportAnnotations; // Restore any saved settings. if (s_StartRef.ContainsKey(m_cache)) { StartRef = s_StartRef[m_cache]; } else { SetStartRefToFirstImportableBook(); } if (s_EndRef.ContainsKey(m_cache)) { EndRef = s_EndRef[m_cache]; } else { SetEndRefToLastImportableBook(); } // Finish constructing the ScrBookControl objects. Paratext.ScrVers versification = scr.Versification; scrPsgFrom.Initialize(new ScrReference(StartRef, versification), scr, m_importSettings.BooksForProject.ToArray()); scrPsgTo.Initialize(new ScrReference(EndRef, versification), scr, m_importSettings.BooksForProject.ToArray()); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Does the import. /// </summary> /// <param name="importSettings">The import settings (can be null, as is the case for /// OXES import).</param> /// <param name="updateDescription">description of the data update being done (i.e., /// which type of import).</param> /// ------------------------------------------------------------------------------------ private void DoImport(ScrImportSet importSettings, string updateDescription) { try { ScrReference firstImported; using (new WaitCursor(m_mainWnd, true)) { FwApp.App.EnableSameProjectWindows(m_cache, false); firstImported = ImportWithUndoTask(importSettings, true, updateDescription); } firstImported = CompleteImport(firstImported); SetSelectionsAfterImport(firstImported); } finally { FwApp.App.EnableSameProjectWindows(m_cache, true); } }
/// ------------------------------------------------------------------------------------ /// <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; } }
public void CleanUp() { CheckDisposed(); m_builder = null; m_cache.ActionHandlerAccessor.EndOuterUndoTask(); m_settings = null; while (m_cache.Undo()) { ; } if (m_cache.DatabaseAccessor.IsTransactionOpen()) { m_cache.DatabaseAccessor.RollbackTrans(); } m_cache.Dispose(); m_cache = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Load the scripture project and enumerator, preparing us to read the data files. /// </summary> /// <param name="settings">Import settings object (filled in by wizard)</param> /// ------------------------------------------------------------------------------------ public void LoadScriptureProject(IScrImportSet settings) { m_settings = settings as ScrImportSet; m_ImportType = settings.ImportTypeEnum; // Load ScriptureText object switch (TypeOfImport) { case TypeOfImport.Paratext6: if (!LoadParatextVernacularProject()) { if (!LoadParatextBackTranslationProject()) { if (!LoadParatextNotesProject()) { throw new InvalidOperationException("There was nothing worth loading."); } } } break; case TypeOfImport.Other: case TypeOfImport.Paratext5: Paratext.ScrVers versification = m_settings.Cache.LangProject.TranslatedScriptureOA.Versification; m_settings.CheckForOverlappingFilesInRange( new ScrReference(m_settings.StartRef, versification), new ScrReference(m_settings.EndRef, versification)); m_scSfmText = new SCScriptureText(settings, ImportDomain.Main); // Now initialize the TextEnum with the range of scripture text we want m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef); break; default: Debug.Assert(false, "bogus TypeOfImport"); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get settings for and perform the Standard Format import /// </summary> /// ------------------------------------------------------------------------------------ protected void ImportSf() { ScrImportSet importSettings = null; // Prevent creation of undo task. using (new SuppressSubTasks(m_cache)) { using (new WaitCursor(m_mainWnd)) { importSettings = GetImportSettings(); } if (importSettings == null) // User cancelled in import wizard { return; } // Display ImportDialog using (ImportDialog importDlg = new ImportDialog(m_styleSheet, m_cache, importSettings, FwApp.App.HelpFile)) { importDlg.ShowDialog(m_mainWnd); if (importDlg.DialogResult == DialogResult.Cancel) { Logger.WriteEvent("User canceled import dialog"); return; } // Settings could have changed if the user went into the wizard. importSettings = importDlg.ImportSettings; } if (!m_importCallbacks.EncourageBackup()) { Logger.WriteEvent("Import canceled in encourage backup dialog"); return; } } DoImport(importSettings, "ImportStandardFormat"); }
public override void Initialize() { base.Initialize(); m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); InitWsInfo(); DummyTeImporter.s_translatorNoteDefn = m_scrInMemoryCache.m_translatorNoteDefn; DummyTeImporter.s_consultantNoteDefn = m_scrInMemoryCache.m_consultantNoteDefn; m_titus = new BCVRef(56001001); m_settings = new DummyScrImportSet(); m_scr.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = TypeOfImport.Other; m_settings.StartRef = m_titus; m_settings.EndRef = m_titus; m_settings.ImportTranslation = true; InitializeImportSettings(); m_importer = new DummyTeImporter(m_settings, Cache, m_styleSheet, m_scrInMemoryCache); m_importer.Initialize(); }
///------------------------------------------------------------------------------- /// <summary> /// Constructor for import dialog, requiring a language project. /// Use this constructor at run time. /// </summary> ///------------------------------------------------------------------------------- public ImportDialog(FwStyleSheet styleSheet, FdoCache cache, ScrImportSet settings, string helpFile) : this() { m_StyleSheet = styleSheet; m_cache = cache; Scripture scr = (Scripture)cache.LangProject.TranslatedScriptureOA; m_importSettings = settings; m_helpFile = helpFile; //InitBookNameList(); // Set the initial values for the controls from the static variables. radImportEntire.Checked = ImportEntire; radImportRange.Checked = !ImportEntire; chkTranslation.Checked = ImportTranslation; chkBackTranslation.Checked = ImportBackTranslation; chkBookIntros.Checked = ImportBookIntros; chkOther.Checked = ImportAnnotations; // Restore any saved settings. if (s_StartRef.ContainsKey(m_cache)) StartRef = s_StartRef[m_cache]; else SetStartRefToFirstImportableBook(); if (s_EndRef.ContainsKey(m_cache)) EndRef = s_EndRef[m_cache]; else SetEndRefToLastImportableBook(); // Finish constructing the ScrBookControl objects. Paratext.ScrVers versification = scr.Versification; scrPsgFrom.Initialize(new ScrReference(StartRef, versification), scr, m_importSettings.BooksForProject.ToArray()); scrPsgTo.Initialize(new ScrReference(EndRef, versification), scr, m_importSettings.BooksForProject.ToArray()); }
public void LoadP6ProjectForAnnotationOnlyImportWithOnlyScriptureProjectSet() { CheckDisposed(); ScrObjWrapper wrapper = new ScrObjWrapper(); ScrImportSet settings = new ScrImportSet(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(settings); Unpacker.UnPackParatextTestProjects(); RegistryData regData = Unpacker.PrepareRegistryForPTData(); try { settings.ImportTypeEnum = TypeOfImport.Paratext6; settings.ParatextScrProj = "KAM"; settings.StartRef = new BCVRef(1, 1, 1); settings.EndRef = new BCVRef(66, 22, 21); settings.ImportAnnotations = true; settings.ImportBackTranslation = false; settings.ImportTranslation = false; wrapper.LoadScriptureProject(settings); string sText, sMarker; ImportDomain domain; Assert.IsTrue(wrapper.GetNextSegment(out sText, out sMarker, out domain)); Assert.AreEqual(3, wrapper.ExternalPictureFolders.Count); Assert.AreEqual(@"C:\~IWTEST~\KAM\Figures", wrapper.ExternalPictureFolders[0]); } finally { if (regData != null) { regData.RestoreRegistryData(); } Unpacker.RemoveParatextTestProjects(); } }
public void LoadP6ProjectForAnnotationOnlyImportWithOnlyScriptureProjectSet() { CheckDisposed(); ScrObjWrapper wrapper = new ScrObjWrapper(); ScrImportSet settings = new ScrImportSet(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(settings); Unpacker.UnPackParatextTestProjects(); RegistryData regData = Unpacker.PrepareRegistryForPTData(); try { settings.ImportTypeEnum = TypeOfImport.Paratext6; settings.ParatextScrProj = "KAM"; settings.StartRef = new BCVRef(1, 1, 1); settings.EndRef = new BCVRef(66, 22, 21); settings.ImportAnnotations = true; settings.ImportBackTranslation = false; settings.ImportTranslation = false; wrapper.LoadScriptureProject(settings); string sText, sMarker; ImportDomain domain; Assert.IsTrue(wrapper.GetNextSegment(out sText, out sMarker, out domain)); Assert.AreEqual(3, wrapper.ExternalPictureFolders.Count); Assert.AreEqual(@"C:\~IWTEST~\KAM\Figures", wrapper.ExternalPictureFolders[0]); } finally { if (regData != null) regData.RestoreRegistryData(); Unpacker.RemoveParatextTestProjects(); } }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the Load event of the ExportPtxDialog control. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event /// data.</param> /// ------------------------------------------------------------------------------------ protected override void OnLoad(EventArgs e) { // set up default short name ScrImportSet importSet = (ScrImportSet)m_cache.LangProject.TranslatedScriptureOA.DefaultImportSettings; m_shortName = (importSet != null) ? importSet.ParatextScrProj : null; if (m_shortName == null) { LgWritingSystem wsVern = ((LgWritingSystem)m_cache.LangProject.CurVernWssRS[0]); string abbr = wsVern.Abbr.UserDefaultWritingSystem; if (abbr != null) { m_shortName = abbr.Trim(); } else { m_shortName = wsVern.Abbreviation.Trim(); } } else { m_shortName = m_shortName.Trim(); } // Paratext 6 requires short name to be between 3 and 5 characters in length. if (m_shortName.Length < 3) { m_shortName = m_shortName.PadRight(3, '_'); } if (m_shortName.Length > 5) { m_shortName = m_shortName.Substring(0, 5); } m_BTshortName = (importSet != null && !string.IsNullOrEmpty(importSet.ParatextBTProj)) ? importSet.ParatextBTProj : (m_shortName.Substring(0, 3) + "BT"); // Set values for what to export for one domain export (Paratext). switch (m_regGroup.GetIntValue("ParatextOneDomainExportWhat", 0)) { case 0: default: // Temporarily load the BT settings, so when we "switch" to Scripture, // the BT settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType + "BT", m_BTshortName); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoScripture.Select(); base.OnLoad(e); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; case 1: // Temporarily load the regular (vern) settings, so when we "switch" to // back translation, the vern settings will be saved in our internal object. LoadFileNameSchemeControl(base.RegistrySettingType, m_shortName); m_fileNameScheme = fileNameSchemeCtrl.FileNameFormat; rdoBackTranslation.Select(); base.OnLoad(e); m_BTfileNameScheme = fileNameSchemeCtrl.FileNameFormat; break; } // Get the output file or folder specification. SCRIPTUREOBJECTSLib.ISCScriptureText3 paraTextSO = null; try { paraTextSO = new SCRIPTUREOBJECTSLib.SCScriptureTextClass(); } catch { // Ignore: Paratext not installed } if (paraTextSO != null) { m_paratextProjFolder = paraTextSO.SettingsDirectory; if (m_paratextProjFolder != null) { m_paratextProjFolder = m_paratextProjFolder.Trim(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); } string[] shortNames = ParatextHelper.GetParatextShortNames(paraTextSO); if (shortNames != null) { foreach (string shortName in shortNames) { bool fIsEditable = true; try { paraTextSO.Load(shortName); fIsEditable = (paraTextSO.Editable != 0); } catch { // Paratext settings file is probably bogus, so we regard it as editable (i.e., we can overwrite it). } if (fIsEditable) { cboShortName.Items.Add(shortName); } else { m_nonEditableP6Projects.Add(shortName); } } } // The following is an attempt to keep us from looking like idiots by making // the default project name a non-editable project. int i = 1; while (m_nonEditableP6Projects.Contains(m_shortName) && i < 1000) { m_shortName = "MP" + i++; } i = 1; while (m_nonEditableP6Projects.Contains(m_BTshortName) && i < 1000) { m_BTshortName = "BT" + i++; } } else { // Paratext is not installed or Paratext directory does not exist. // We default the output path to "C:\My Paratext Projects". However, this directory // might not exist and/or we might have no permissions to write there. We attempt to // create this folder now. If we fail, then we disable the Short Name control and // won't bother writing the Paratext settings files. m_paratextProjFolder = kDefaultParatextPath; } cboShortName.Text = ShortName; m_OutputFolder = m_regGroup.GetStringValue("ParatextOutputSpec", m_paratextProjFolder); m_BTOutputFolder = m_regGroup.GetStringValue("ParatextBTOutputSpec", m_paratextProjFolder); UpdateDisplay(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="importSettings"></param> /// ------------------------------------------------------------------------------------ public void ImportFile(ScrImportSet importSettings) { CheckDisposed(); TestImportManager.ImportWithUndoTask(this, importSettings); }
/// <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 override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { if (!MiscUtils.IsUserAdmin) RegistryRedirect.ResetRegistry(); // Dispose managed resources here. if (m_dataFiles != null) { m_dataFiles.CleanUp(); m_dataFiles = null; } if (m_regDataSettingsDir != null) { m_regDataSettingsDir.RestoreRegistryData(); m_regDataSettingsDir = null; } } m_regDataSettingsDir = null; m_dataFiles = null; m_settings = null; // Dispose unmanaged resources here, whether disposing is true or false. base.Dispose(disposing); }
/// <summary></summary> public DummySCScriptureText(ScrImportSet settings, ImportDomain domain): base(settings, domain) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Import scripture and embed it in a Undo task so that it is undoable. /// </summary> /// <param name="importSettings">Import settings</param> /// <param name="segmentList">The segment list.</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ internal void CallImportWithUndoTask(ScrImportSet importSettings, List<SegmentInfo> segmentList) { m_segmentList = segmentList; CompleteImport(ImportWithUndoTask(importSettings, false, string.Empty)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DummyImportDialog"/> class. /// </summary> /// <param name="styleSheet">The style sheet.</param> /// <param name="cache">The cache.</param> /// <param name="settings">The settings.</param> /// ------------------------------------------------------------------------------------ public DummyImportDialog(FwStyleSheet styleSheet, FdoCache cache, ScrImportSet settings) : base(styleSheet, cache, settings, string.Empty) { }
/// ------------------------------------------------------------------------------------ /// <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 override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. if (m_importer != null) m_importer.Dispose(); } // Dispose unmanaged resources here, whether disposing is true or false. m_styleSheet = null; // FwStyleSheet should implement IDisposable. m_settings = null; m_importer = null; // TeImporter should implement IDisposable. if (m_ttpVernWS != null) { // Marshal.ReleaseComObject(m_ttpVernWS); m_ttpVernWS = null; } if (m_ttpAnalWS != null) { // Marshal.ReleaseComObject(m_ttpAnalWS); m_ttpAnalWS = null; } base.Dispose(disposing); }
public void UndoImport_NewBook() { FdoCache cache = m_firstMainWnd.Cache; Scripture scr = (Scripture)m_firstMainWnd.ScriptureObj; Set<int> origDrafts = new Set<int>(scr.ArchivedDraftsOC.HvoArray); // Create a settings object and set it to be a Paratext import of Titus. ScrImportSet settings = new ScrImportSet(); scr.ImportSettingsOC.Add(settings); settings.ImportTypeEnum = TypeOfImport.Paratext6; settings.ParatextScrProj = "TEV"; settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\it", @"\it*", false, MappingTargetType.TEStyle, MarkerDomain.Default, "Emphasis", null)); cache.Save(); // Setup the reference to import. BCVRef scrRef = new BCVRef(56001001); // Do the import. settings.ImportTranslation = true; settings.ImportBookIntros = true; settings.StartRef = scrRef; settings.EndRef = scrRef; m_firstMainWnd.Import(settings); IScrDraft importedDrafts = GetImportedVersion(cache, origDrafts, 1); Assert.IsNotNull(importedDrafts.FindBook(56)); Assert.IsTrue(cache.ActionHandlerAccessor.CanUndo()); Assert.AreEqual(UndoResult.kuresRefresh, cache.ActionHandlerAccessor.Undo()); Assert.IsNull(scr.FindBook(56)); // JohnT: no longer happens, and I can't think why it should, since Undo does not // change Scripture. Set<int> finalDrafts = new Set<int>(scr.ArchivedDraftsOC.HvoArray); Assert.AreEqual(origDrafts.Count, finalDrafts.Count); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Defines the import settings given a type of import (Paratext5, Paratext6 or Other). /// Either we find import settings in the database or create a new set. /// </summary> /// <param name="importType">Type of the import.</param> /// ------------------------------------------------------------------------------------ private void DefineImportSettings(TypeOfImport importType) { IScrImportSet settings = ((Scripture)m_scr).FindImportSettings(importType); if (settings == null) { m_settings = new ScrImportSet(); m_scr.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = importType; } else m_settings = (ScrImportSet)settings; InitializeScrImportSettings(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for runtime. /// </summary> /// <param name="langProjName">Name of the lang proj.</param> /// <param name="scr">The Scripture object.</param> /// <param name="styleSheet">The styleSheet</param> /// <param name="cache">The cache</param> /// <param name="sHelpFile">If null, the help button will be hidden</param> /// ------------------------------------------------------------------------------------ public ImportWizard(string langProjName, Scripture scr, FwStyleSheet styleSheet, FdoCache cache, string sHelpFile) : this() { m_LangProjName = langProjName; m_scr = scr; m_StyleSheet = styleSheet; m_resolver = new ConfirmOverlappingFileReplaceDialog(); m_settings = (ScrImportSet)m_scr.DefaultImportSettings; if (m_settings == null) { m_settings = new ScrImportSet(); m_scr.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = TypeOfImport.Paratext6; } InitializeScrImportSettings(); // Initialize controls based on settings provided switch (m_settings.ImportTypeEnum) { case TypeOfImport.Paratext6: rbParatext6.Checked = true; break; case TypeOfImport.Other: rbOther.Checked = true; break; case TypeOfImport.Paratext5: rbParatext5.Checked = true; break; } m_cache = cache; m_helpFile = sHelpFile; if (m_helpFile == null) m_btnHelp.Visible = false; if (FwApp.App != null) { m_LatestImportFolder = new RegistryStringSetting(FwSubKey.TE, cache.ServerName, cache.DatabaseName, "LatestImportDirectory", string.Empty); sfFileListBuilder.LatestImportFolder = m_LatestImportFolder.Value; } if (m_StyleSheet != null) { m_scrViewHelper = new StyleListViewHelper(lvScrMappings, 1); m_scrViewHelper.AddStyles(m_StyleSheet as FwStyleSheet, MappingDetailsCtrl.AllPseudoStyles); m_annotationViewHelper = new StyleListViewHelper(lvAnnotationMappings, 1); m_annotationViewHelper.AddStyles(m_StyleSheet as FwStyleSheet, MappingDetailsCtrl.AllPseudoStyles); } }
public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); m_cache = FdoCache.Create("TestLangProj"); // Make sure we don't call InstallLanguage during tests. m_cache.LanguageWritingSystemFactoryAccessor.BypassInstall = true; m_scr = m_cache.LangProject.TranslatedScriptureOA; m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(m_cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); if (!m_cache.DatabaseAccessor.IsTransactionOpen()) m_cache.DatabaseAccessor.BeginTrans(); // By default, use auto-generated footnote markers for import tests. m_scr.FootnoteMarkerType = FootnoteMarkerTypes.AutoFootnoteMarker; m_titus = new BCVRef(56001001); m_settings = new ScrImportSet(); m_scr.ImportSettingsOC.Add(m_settings); //m_scr.DefaultImportSettings = m_settings; DummyTeImporter.MakeSFImportTestSettings(m_settings); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { CheckDisposed(); m_scrInMemoryCache.InitializeScripture(); m_scrInMemoryCache.InitializeAnnotationDefs(); m_settings = new ScrImportSet(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = TypeOfImport.Other; }
/// ------------------------------------------------------------------------------------ /// <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 override void Dispose(bool disposing) { Debug.WriteLine("Start of Dispose"); //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. if (m_cache != null) { if (m_cache.DatabaseAccessor.IsTransactionOpen()) m_cache.DatabaseAccessor.RollbackTrans(); m_cache.Dispose(); } } m_cache = null; m_importMgr = null; m_scr = null; m_styleSheet = null; // FwStyleSheet should implement IDisposable. m_settings = null; Debug.WriteLine("Before calling base.Dispose"); base.Dispose(disposing); Debug.WriteLine("End of Dispose"); }
public void Init() { CheckDisposed(); m_builder = new DummySFFileListBuilder(); m_cache = FdoCache.Create("TestLangProj"); if (!m_cache.DatabaseAccessor.IsTransactionOpen()) m_cache.DatabaseAccessor.BeginTrans(); m_cache.BeginUndoTask("Undo SfFileListBuilderTest", "Redo SfFileListBuilderTest"); m_settings = new ScrImportSet(); m_cache.LangProject.TranslatedScriptureOA.DefaultImportSettings = m_settings; }
public void CleanUp() { CheckDisposed(); if (m_DummyImportWizard != null) { if (m_DummyImportWizard.MappingDialog != null) m_DummyImportWizard.MappingDialog.Close(); m_DummyImportWizard.Close(); m_DummyImportWizard = null; } m_settings = null; m_cache.ActionHandlerAccessor.EndOuterUndoTask(); while (m_cache.Undo()); if (m_cache.DatabaseAccessor.IsTransactionOpen()) m_cache.DatabaseAccessor.RollbackTrans(); m_cache.Dispose(); m_Scripture = null; m_cache = null; }
public void CleanUp() { CheckDisposed(); m_builder = null; m_cache.ActionHandlerAccessor.EndOuterUndoTask(); m_settings = null; while (m_cache.Undo()) ; if (m_cache.DatabaseAccessor.IsTransactionOpen()) m_cache.DatabaseAccessor.RollbackTrans(); m_cache.Dispose(); m_cache = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Populate m_settings as if user had used the Import Wizard to choose a Paratext /// project and set up mappings. /// </summary> /// <param name="settings">Import settings</param> /// ------------------------------------------------------------------------------------ static public void MakeParatextImportTestSettings(ScrImportSet settings) { settings.ImportTypeEnum = TypeOfImport.Paratext6; // Set project settings.ParatextScrProj = "TEV"; // Set up the mappings DummyTeImporter.SetUpMappings(settings); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Load the scripture project and enumerator, preparing us to read the data files. /// </summary> /// <param name="settings">Import settings object (filled in by wizard)</param> /// ------------------------------------------------------------------------------------ public void LoadScriptureProject(IScrImportSet settings) { m_settings = settings as ScrImportSet; m_ImportType = settings.ImportTypeEnum; // Load ScriptureText object switch (TypeOfImport) { case TypeOfImport.Paratext6: if (!LoadParatextVernacularProject()) if (!LoadParatextBackTranslationProject()) if (!LoadParatextNotesProject()) throw new InvalidOperationException("There was nothing worth loading."); break; case TypeOfImport.Other: case TypeOfImport.Paratext5: Paratext.ScrVers versification = m_settings.Cache.LangProject.TranslatedScriptureOA.Versification; m_settings.CheckForOverlappingFilesInRange( new ScrReference(m_settings.StartRef, versification), new ScrReference(m_settings.EndRef, versification)); m_scSfmText = new SCScriptureText(settings, ImportDomain.Main); // Now initialize the TextEnum with the range of scripture text we want m_scTextEnum = m_scSfmText.TextEnum(m_settings.StartRef, m_settings.EndRef); break; default: Debug.Assert(false, "bogus TypeOfImport"); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the settings for Import, either from database or from wizard /// </summary> /// <returns>Import settings, or <c>null</c> if user canceled dialog.</returns> /// ------------------------------------------------------------------------------------ protected ScrImportSet GetImportSettings() { ILangProject proj = m_cache.LangProject; Scripture scr = (Scripture)proj.TranslatedScriptureOA; ScrImportSet importSettings = new ScrImportSet(m_cache, scr.DefaultImportSettingsHvo, m_styleSheet, FwApp.App.HelpFile); importSettings.OverlappingFileResolver = new ConfirmOverlappingFileReplaceDialog(); if (!importSettings.BasicSettingsExist) { // REVIEW DavidO: Should I use AnalysisDefaultWritingSystem or // VernacularDefaultWritingSystem or something else. using (ImportWizard importWizard = new ImportWizard(proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache, FwApp.App.HelpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { return(null); } // Scripture reference range may have changed ImportDialog.ClearDialogReferences(m_cache); importSettings = (ScrImportSet)scr.DefaultImportSettings; } } else { StringCollection sInvalidFiles; bool fCompletedWizard = false; while (!importSettings.ImportProjectIsAccessible(out sInvalidFiles)) { // Display the "Project Not Found" message box using (ScrImportSetMessage dlg = new ScrImportSetMessage()) { string[] files = new string[sInvalidFiles.Count]; sInvalidFiles.CopyTo(files, 0); dlg.InvalidFiles = files; dlg.HelpURL = FwApp.App.HelpFile; dlg.HelpTopic = "/Beginning_Tasks/Import_Standard_Format/Project_Files_Unavailable.htm"; dlg.DisplaySetupOption = true; switch (dlg.ShowDialog()) { case DialogResult.OK: // Setup... { using (ImportWizard importWizard = new ImportWizard( proj.Name.UserDefaultWritingSystem, scr, m_styleSheet, m_cache, FwApp.App.HelpFile)) { if (importWizard.ShowDialog() == DialogResult.Cancel) { return(null); } // Scripture reference range may have changed ImportDialog.ClearDialogReferences(m_cache); importSettings = (ScrImportSet)scr.DefaultImportSettings; fCompletedWizard = true; } break; } case DialogResult.Cancel: return(null); case DialogResult.Retry: // Loop around until user gets tired. break; } } } if (!fCompletedWizard) { if (ParatextProjHasUnmappedMarkers(importSettings)) { // TODO: Show message box and then bring up import wizard } } } return(importSettings); }
/// ------------------------------------------------------------------------------------ /// Populate m_settings as if user had used the Import Wizard to choose a SF project /// and set up mappings appropriate for TOB data files. /// </summary> /// <param name="settings">Import settings</param> /// ------------------------------------------------------------------------------------ static public void MakeSFImportTestSettings(ScrImportSet settings) { settings.ImportTypeEnum = TypeOfImport.Other; // add TOB files to the project settings.AddFile(DriveUtil.BootDrive + @"sf_scr~files2003.~TOB~\32JON.sfm", ImportDomain.Main, null, 0); settings.AddFile(DriveUtil.BootDrive + @"sf_scr~files2003.~TOB~\123JN.sfm", ImportDomain.Main, null, 0); // add TEV Philemon file to the project settings.AddFile(DriveUtil.BootDrive + @"~IWTEST~\TEV\58Phm.tev", ImportDomain.Main, null, 0); // Set up the mappings DummyTeImporter.SetUpMappings(settings); }
public void VerifyStylesComboBoxAfterImport() { Unpacker.UnpackTEVTitusWithUnmappedStyle(); try { // Move selection to a place in the text where the styles combo contents // are not restricted to exclude general paragraphs (Jud 1:10 will do). m_firstDraftView.GotoVerse(65001010); // Make sure the style combo box doesn't have the UnknownTEStyle in it. Assert.IsTrue(m_firstMainWnd.ParaStylesComboBox.FindString(@"\xx") < 0, @"'\xx' was found!"); // Create a settings object and set it to be a Paratext import of the // TEV scripture project (containing Titus with an unmapped marker). IScripture scr = (Scripture)m_firstMainWnd.ScriptureObj; IScrImportSet settings = new ScrImportSet(); scr.ImportSettingsOC.Add(settings); scr.DefaultImportSettings = settings; settings.ImportTypeEnum = TypeOfImport.Paratext6; settings.ParatextScrProj = "TEV"; // Setup the reference to import. BCVRef scrRef = new BCVRef(56001001); // Do the import. settings.ImportTranslation = true; (settings as ScrImportSet).StartRef = scrRef; (settings as ScrImportSet).EndRef = scrRef; m_firstMainWnd.Import(settings); m_firstMainWnd.InitStyleComboBox(); // Move selection back to Jud 1:10 because the selection seems to get messed // up in this test. m_firstDraftView.GotoVerse(65001010); // Make sure the styles combo now contains a new style for the unmapped marker // found in our test TEV style sheet and in the test Titus scripture data // (the style file and scripture data file contain the unmapped marker '\xx'). Assert.IsTrue(m_firstMainWnd.ParaStylesComboBox.FindString(@"\xx") >= 0, @"'\xx' was not found!"); } finally { Unpacker.UnPackParatextTestProjects(); } }
public void UndoImport_ReplaceBook() { FdoCache cache = m_firstMainWnd.Cache; Scripture scr = (Scripture)m_firstMainWnd.ScriptureObj; Set<int> origDrafts = new Set<int>(scr.ArchivedDraftsOC.HvoArray); // Create a settings object and set it to be a Paratext import of Philemon. ScrImportSet settings = new ScrImportSet(); scr.ImportSettingsOC.Add(settings); settings.ImportTypeEnum = TypeOfImport.Paratext6; settings.ParatextScrProj = "TEV"; settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\it", @"\it*", false, MappingTargetType.TEStyle, MarkerDomain.Default, "Emphasis", null)); cache.Save(); // Setup the reference to import. BCVRef scrRef = new BCVRef(57001001); // Do the import. settings.ImportTranslation = true; settings.ImportBookIntros = true; settings.StartRef = scrRef; settings.EndRef = scrRef; m_firstMainWnd.Import(settings); IScrDraft importedDraft = GetImportedVersion(cache, origDrafts, 2); IScrBook importedPhm = importedDraft.FindBook(57); Assert.IsNotNull(importedPhm); Assert.IsTrue(cache.ActionHandlerAccessor.CanUndo()); Assert.AreEqual(UndoResult.kuresRefresh, cache.ActionHandlerAccessor.Undo()); IScrBook restoredPhm = scr.FindBook(57); Assert.IsNotNull(restoredPhm); Assert.AreNotEqual(restoredPhm.Hvo, importedPhm.Hvo); Set<int> finalDrafts = new Set<int>(scr.ArchivedDraftsOC.HvoArray); Assert.AreEqual(origDrafts.Count, finalDrafts.Count); }
/// ------------------------------------------------------------------------------------ /// <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 override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. if (m_dlg != null) m_dlg.Dispose(); if (m_regData != null) { m_regData.RestoreRegistryData(); } Unpacker.RemoveParatextTestProjects(); } // Dispose unmanaged resources here, whether disposing is true or false. m_dlg = null; m_regData = null; m_settings = null; base.Dispose(disposing); }