Esempio n. 1
0
		public void Deinitialize()
		{
			CheckDisposed();
			m_exporter = null;
			m_cache.Dispose();
			m_cache = null;
			m_filter = null;
			File.Delete(m_fileName);
			m_fileName = null;
		}
Esempio n. 2
0
		public override void Initialize()
		{
			CheckDisposed();
			m_cache = FdoCache.Create("TestLangProj");
			m_filter = new FilteredScrBooks(m_cache, 123);
			m_filter.ShowAllBooks();
			m_fileName = Path.GetTempFileName();
			File.Delete(m_fileName);	// exporter pops up dialog if file exists!
			m_exporter = new ExportXml(m_fileName, m_cache, m_filter,
				ExportWhat.AllBooks, 0, 0, 0, "This is a test");
		}
Esempio n. 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle the File/Export/Xml menu command
		/// </summary>
		/// <param name="args"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected bool OnFileExportXml(object args)
		{
			AdjustScriptureAnnotations();
			using (ExportXmlDialog dlg = new ExportXmlDialog(m_cache, m_bookFilter, GetReferenceToCurrentBook().Book,
				m_StyleSheet, FileType.OXES, m_app))
			{
				if (dlg.ShowDialog() == DialogResult.OK)
				{
					string filename = Path.GetFileName(dlg.FileName);
					string directory = Path.GetDirectoryName(dlg.FileName);
					// REVIEW (TimS): What does this code accomplish? It seems to just re-create
					// dlg.FileName in parts.
					if (directory.EndsWith(Path.VolumeSeparatorChar.ToString()))
						directory += Path.DirectorySeparatorChar;

					ExportXml export = new ExportXml(Path.Combine(directory, filename), m_cache,
						m_bookFilter, m_app, dlg.ExportWhat, dlg.BookNumber, dlg.FirstSection,
						dlg.LastSection, dlg.Description);
					if (export.Run(this))
					{
						// Validate the XML file. If it doesn't pass validation, display a
						// yellow error message box.
						string strError = Validator.GetAnyValidationErrors(export.FileName);
						if (!String.IsNullOrEmpty(strError))
							throw new ContinuableErrorException(strError);
					}
				}
			}
			return true;
		}
Esempio n. 4
0
		public void ExportPicture_MultipleWS()
		{
			// Create a picture that has a caption with three different writing systems.
			ITsStrBldr tssBldr = TsStrBldrClass.Create();
			ITsPropsBldr propsBldr = TsPropsBldrClass.Create();
			propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, InMemoryFdoCache.s_wsHvos.De);
			tssBldr.ReplaceRgch(0, 0, "photo", 5, propsBldr.GetTextProps());
			propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, InMemoryFdoCache.s_wsHvos.Ur);
			tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " tasvir", 7, propsBldr.GetTextProps());
			propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, Cache.DefaultVernWs);
			tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " picture caption", 16, propsBldr.GetTextProps());
			CmPicture picture = new CmPicture(m_inMemoryCache.Cache, @"c:\filename.jpg", tssBldr.GetString(), "folder");

			// Set up for export
			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);
			writer.Formatting = Formatting.None;
			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportPicture_MultipleWS");
			ReflectionHelper.SetField(m_exporter, "m_writer", writer);

			// Export the picture to XML
			ReflectionHelper.CallMethod(m_exporter, "ExportPicture", picture);

			// Check the results of the exported picture.
			//   Set up expected results.
			string defaultDir = DirectoryFinder.FWDataDirectory;
			// TODO (TE-7756): Support OXES export and import of new properties that have been
			// added to the CmPicture model
			string strExpected = "<figure src=\"filename.jpg\"><!--path=\"" + defaultDir + "\\filename\"-->" +
				"<caption><trGroup><tr><foreign xml:lang=\"de\">photo</foreign>" +
				"<foreign xml:lang=\"ur\"> tasvir</foreign> picture caption</tr></trGroup></caption></figure>";
			XmlDocument expected = new XmlDocument();
			expected.Load(new StringReader(strExpected));

			//   Get actual results.
			XmlDocument actual = new XmlDocument();
			actual.Load(new StringReader(stream.ToString()));

			string strDifference;
			if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
				Assert.Fail(strDifference);
		}
Esempio n. 5
0
		public void ExportBookSection_MultipleBT()
		{
			Cache.LangProject.AnalysisWssRC.Add(InMemoryFdoCache.s_wsHvos.Hbo);
			Cache.LangProject.CurAnalysisWssRS.Append(InMemoryFdoCache.s_wsHvos.Hbo);
			int wsAnal = Cache.DefaultAnalWs;
			IScrSection introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_book.Hvo);
			m_scrInMemoryCache.AddSectionHeadParaToSection(introSection.Hvo, "Introduccion",
				ScrStyleNames.IntroSectionHead);
			StTxtPara introPara = AddPara(introSection, ScrStyleNames.NormalParagraph);
			AddVerse(introPara, 0, 0, "Texto de introduccion");

			// Add a back translation for the default analysis language.
			CmTranslation trans = (CmTranslation)m_scrInMemoryCache.AddTransToMockedParagraph(introPara,
				LangProject.kguidTranBackTranslation, wsAnal);
			trans.Translation.SetAlternative("Default BT", wsAnal);
			trans.Status.SetAlternative("finished", wsAnal);

			// Add a back translation for Hebrew.
			trans.Translation.SetAlternative("Hbo BT", InMemoryFdoCache.s_wsHvos.Hbo);

			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);
			writer.Formatting = Formatting.None;
			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportBookSection_IntroWithNotes");
			// Initialize writing systems for export (required to export back translations), but
			// called from ExportTE.
			ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null);
			ReflectionHelper.SetField(m_exporter, "m_writer", writer);
			string sCanon = "ot";
			ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null);

			XmlDocument actual = new XmlDocument();
			actual.Load(new StringReader(stream.ToString()));
			string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" +
				"<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" +
				"<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" +
				"<p><trGroup><tr><userCS type=\"Paragraph\">Some intro text</userCS></tr>" +
				"<bt xml:lang=\"en\" status=\"finished\">Default BT</bt><bt xml:lang=\"hbo\">Hbo BT</bt></trGroup>" +
				"<chapterEnd ID=\"GEN.0\"/></p></section></introduction></book>";

			XmlDocument expected = new XmlDocument();
			expected.Load(new StringReader(strExpected));

			string strDifference;
			if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
				Assert.Fail(strDifference);
		}
Esempio n. 6
0
		public void ExportBookSection_BTIntroWithNotes()
		{
			int wsAnal = Cache.DefaultAnalWs;
			IScrSection introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_book.Hvo);
			m_scrInMemoryCache.AddSectionHeadParaToSection(introSection.Hvo, "Introduccion",
				ScrStyleNames.IntroSectionHead);
			StTxtPara introPara = AddPara(introSection, ScrStyleNames.NormalParagraph);
			AddVerse(introPara, 0, 0, "Texto de introduccion");
			CmTranslation trans = (CmTranslation)m_scrInMemoryCache.AddTransToMockedParagraph(introPara,
				LangProject.kguidTranBackTranslation, wsAnal);
			trans.Translation.SetAlternative("Introduction text", wsAnal);
			ScrScriptureNote note = (ScrScriptureNote)m_scrInMemoryCache.AddAnnotation(trans,
				01001000, NoteType.Consultant, "This is a basic note about the BT of an intro.");
			note.ResolutionStatus = NoteStatus.Open;
			note.BeginOffset = 0;
			note.EndOffset = 5;
			note.WsSelector = wsAnal;

			DateTime now = DateTime.Now;
			string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff");
			note.DateCreated = now;
			note.DateModified = now;

			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);
			writer.Formatting = Formatting.None;
			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportBookSection_IntroWithNotes");
			// Initialize writing systems for export (required to export back translations), but
			// called from ExportTE.
			ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null);
			ReflectionHelper.SetField(m_exporter, "m_writer", writer);
			string sCanon = "ot";
			ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null);

			XmlDocument actual = new XmlDocument();
			actual.Load(new StringReader(stream.ToString()));
			string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" +
				"<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" +
				"<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" +
				"<p><annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" beginOffset=\"0\" " +
				"endOffset=\"5\" languageInFocus=\"en\">" +
				"<created>" + strNow + "</created><modified>" + strNow + "</modified>" +
				"<resolved /><notationDiscussion><para xml:lang=\"en\">" +
				"<run>This is a basic note about the BT of an intro.</run></para></notationDiscussion></annotation>" +
				"<trGroup><tr><userCS type=\"Paragraph\">Some intro text</userCS></tr>" +
				"<bt xml:lang=\"en\">Texto de introduccion</bt></trGroup>" +
				"<chapterEnd ID=\"GEN.0\"/></p></section></introduction></book>";

			XmlDocument expected = new XmlDocument();
			expected.Load(new StringReader(strExpected));

			string strDifference;
			if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
				Assert.Fail(strDifference);
		}
Esempio n. 7
0
		public void ExportBookSection_IntroWithNotes()
		{
			IScrSection introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_book.Hvo);
			m_scrInMemoryCache.AddSectionHeadParaToSection(introSection.Hvo, "Introduction",
				ScrStyleNames.IntroSectionHead);
			StTxtPara introPara = AddPara(introSection, ScrStyleNames.NormalParagraph);
			AddVerse(introPara, 0, 0, "Some intro text");
			IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(introPara, new BCVRef(01001000),
				NoteType.Consultant, "This is a basic note about the intro.");
			note.ResolutionStatus = NoteStatus.Open;
			note.BeginOffset = 5;
			note.EndOffset = 10;

			DateTime now = DateTime.Now;
			string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff");
			note.DateCreated = now;
			note.DateModified = now;

			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);
			writer.Formatting = Formatting.None;
			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportBookSection_IntroWithNotes");

			ReflectionHelper.SetField(m_exporter, "m_writer", writer);
			string sCanon = "ot";
			ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null);


			XmlDocument actual = new XmlDocument();
			actual.Load(new StringReader(stream.ToString()));
			string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" +
				"<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" +
				"<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" +
				"<p><annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" beginOffset=\"5\" endOffset=\"10\">" +
				"<created>" + strNow + "</created><modified>" + strNow + "</modified>" +
				"<resolved /><notationDiscussion><para xml:lang=\"en\">" +
				"<run>This is a basic note about the intro.</run></para></notationDiscussion></annotation>" +
				"<trGroup><tr><userCS type=\"Paragraph\">Some intro text</userCS></tr></trGroup>" +
				"<chapterEnd ID=\"GEN.0\"/></p></section></introduction></book>";

			XmlDocument expected = new XmlDocument();
			expected.Load(new StringReader(strExpected));

			string strDifference;
			if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
				Assert.Fail(strDifference);
		}
Esempio n. 8
0
		public void ExportScriptureNote_IgnoredCheckingError()
		{
			IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = AddPara(section, ScrStyleNames.NormalParagraph);
			IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001),
				NoteType.CheckingError, "This is some basic text.");
			note.AnnotationTypeRA.Name.SetAlternative("Repeated Words", Cache.DefaultAnalWs);
			note.AnnotationTypeRA.Guid = new Guid(StandardCheckIds.kguidRepeatedWords.ToString());
			note.ResolutionStatus = NoteStatus.Closed;
			DateTime now = DateTime.Now;
			string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff");
			note.DateCreated = now;
			note.DateModified = now;
			note.DateResolved = now;

			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);
			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportScriptureNote_Resolved");

			ReflectionHelper.SetField(m_exporter, "m_writer", writer);
			ReflectionHelper.CallMethod(m_exporter, "ExportScriptureNote", note);
			string strExpected = "<annotation subType=\"repeatedWordsCheck\" status=\"1\" oxesRef=\"GEN.1.1\" " +
							"beginOffset=\"0\" endOffset=\"0\" type=\"pre-typesettingCheck\">" +
							"<created>" + strNow + "</created>" +
							"<modified>" + strNow + "</modified>" +
							"<resolved>" + strNow + "</resolved>" +
							"<notationDiscussion>" +
								"<para xml:lang=\"en\">" +
									"<span>This is some basic text.</span>" +
								"</para>" +
							"</notationDiscussion>" +
						"</annotation>";

			XmlDocument actual = new XmlDocument();
			actual.Load(new StringReader(stream.ToString()));

			XmlDocument expected = new XmlDocument();
			expected.Load(new StringReader(strExpected));

			string strDifference;
			if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
				Assert.Fail(strDifference);
		}
Esempio n. 9
0
		public void ExportNotationParagraphs_Hyperlink()
		{
			IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.NormalParagraph);
			IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001),
				NoteType.Translator, "This is some text with a hyperlink!");
			TsStringAccessor tssaDisc = ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents;
			tssaDisc.MarkTextAsHyperlink(tssaDisc.Length - 10, tssaDisc.Length - 1,
				"http://www.myspace.com", m_stylesheet);

			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);
			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportNotationParagraphs_Hyperlink");

			ReflectionHelper.SetField(m_exporter, "m_writer", writer);
			ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA,
				"notationDiscussion");
			Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" +
				"<span>This is some text with a </span>" +
				"<a href=\"http://www.myspace.com\">hyperlink</a>" +
				"<span>!</span>" +
				"</para></notationDiscussion>", stream.ToString());
		}
Esempio n. 10
0
		public void ExportScriptureNotesOutOfOrder()
		{
			IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);

			// Create 2 paragraphs
			StTxtPara para1 = AddPara(section, ScrStyleNames.NormalParagraph);
			StTxtPara para2 = AddPara(section, ScrStyleNames.NormalParagraph);

			// Add an annotation to the second paragraph. Ref.
			// GEN 1 means annotation is in an introduction paragraph.
			IScrScriptureNote note1 = m_scrInMemoryCache.AddAnnotation(
				para2, new BCVRef(01001000), NoteType.Consultant, "Annotation1 for Para2");

			// Add an annotation to the first paragraph.
			// GEN 1 means annotation is in an introduction paragraph.
			IScrScriptureNote note2 = m_scrInMemoryCache.AddAnnotation(
				para1, new BCVRef(01001000), NoteType.Consultant, "Annotation2 for Para1");

			DateTime now = DateTime.Now;
			string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff");
			note1.DateCreated = note2.DateCreated = now;
			note1.DateModified = note2.DateModified = now;
			note1.DateResolved = note2.DateResolved = now;

			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);

			writer.WriteStartElement("TestData");

			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportScriptureNotesOutOfOrder");

			ReflectionHelper.SetField(m_exporter, "m_writer", writer);
			ReflectionHelper.SetField(m_exporter, "m_iCurrentBook", 1);
			ReflectionHelper.CallMethod(m_exporter, "ExportAnnotationsForPara", para1.Hvo);
			ReflectionHelper.CallMethod(m_exporter, "ExportAnnotationsForPara", para2.Hvo);

			writer.WriteEndElement();

			string strExpected = "<TestData>" +
				"<annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" " +
							"beginOffset=\"0\" endOffset=\"0\">" +
							"<created>" + strNow + "</created>" +
							"<modified>" + strNow + "</modified>" +
							"<resolved />" +
							"<notationDiscussion>" +
								"<para xml:lang=\"en\">" +
									"<span>Annotation2 for Para1</span>" +
								"</para>" +
							"</notationDiscussion>" +
						"</annotation>" +
						"<annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" " +
							"beginOffset=\"0\" endOffset=\"0\">" +
							"<created>" + strNow + "</created>" +
							"<modified>" + strNow + "</modified>" +
							"<resolved />" +
							"<notationDiscussion>" +
								"<para xml:lang=\"en\">" +
									"<span>Annotation1 for Para2</span>" +
								"</para>" +
							"</notationDiscussion>" +
						"</annotation></TestData>";

			XmlDocument actual = new XmlDocument();
			actual.Load(new StringReader(stream.ToString()));

			XmlDocument expected = new XmlDocument();
			expected.Load(new StringReader(strExpected));

			string strDifference;
			if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference))
				Assert.Fail(strDifference);
		}
Esempio n. 11
0
		public void ExportNotationParagraphs_WritingSystems()
		{
			IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.NormalParagraph);
			IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001),
				NoteType.Translator, "This is some text with espa\u00F1ol.");
			TsStringAccessor tssaDisc = ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents;
			ITsStrBldr bldr = tssaDisc.UnderlyingTsString.GetBldr();
			bldr.SetProperties(bldr.Length - 8, bldr.Length - 1,
				StyleUtils.CharStyleTextProps(null, InMemoryFdoCache.s_wsHvos.Es));
			tssaDisc.UnderlyingTsString = bldr.GetString();

			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);
			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportNotationParagraphs_WritingSystems");

			ReflectionHelper.SetField(m_exporter, "m_writer", writer);
			ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA,
				"notationDiscussion");
			Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" +
				"<span>This is some text with </span>" +
				"<span xml:lang=\"es\">espa\u00F1ol</span>" +
				"<span>.</span>" +
				"</para></notationDiscussion>", stream.ToString());
		}
Esempio n. 12
0
		public void ExportNotationParagraphs_Basic()
		{
			IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo);
			StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo,
				ScrStyleNames.NormalParagraph);
			IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001),
				NoteType.Translator, "This is some basic text.");
			TsStringAccessor tssaDisc = ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents;

			StringWriter stream = new StringWriter();
			XmlTextWriter writer = new XmlTextWriter(stream);
			m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0,
				"ExportNotationParagraphs_Basic");

			ReflectionHelper.SetField(m_exporter, "m_writer", writer);
			ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA,
				"notationDiscussion");
			Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" +
				"<span>This is some basic text.</span>" +
				"</para></notationDiscussion>", stream.ToString());
		}
Esempio n. 13
0
		public override void Exit()
		{
			CheckDisposed();

			m_exporter = null;
			m_filter = null;
			if (m_fileName != null)
				File.Delete(m_fileName);
			m_stylesheet = null;
			m_fileName = null;

			Options.UseInterlinearBackTranslation = m_saveSegmentedBT;

			base.Exit();
		}
Esempio n. 14
0
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			m_fileName = Path.GetTempFileName();
			File.Delete(m_fileName);	// exporter pops up dialog if file exists!
			m_scrInMemoryCache.InitializeScripture();
			m_scrInMemoryCache.InitializeWritingSystemEncodings();
			m_stylesheet = new FwStyleSheet();
			m_stylesheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles);
			m_scrInMemoryCache.InitializeAnnotationDefs();

			m_book = m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis");
			m_scrInMemoryCache.AddTitleToMockedBook(m_book.Hvo, "Genesis");

			m_filter = new FilteredScrBooks(Cache, 123);
			m_filter.ShowAllBooks();

			m_saveSegmentedBT = Options.UseInterlinearBackTranslation;
			Options.UseInterlinearBackTranslation = false;

			m_exporter = new ExportXml(m_fileName, Cache, m_filter, ExportWhat.AllBooks, 0, 0, 0,
				string.Empty);
		}
Esempio n. 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle the File/Export/Xml menu command
		/// </summary>
		/// <param name="args"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected bool OnFileExportXml(object args)
		{
			AdjustScriptureAnnotations();
			ScrReference refBook = GetReferenceToCurrentBook();
			using (ExportXmlDialog dlg = new ExportXmlDialog(m_cache, m_bookFilter, refBook,
				m_StyleSheet, FileType.OXES))
			{
				if (dlg.ShowDialog() == DialogResult.OK)
				{
					ExportXml export = new ExportXml(dlg.FileName, m_cache, m_bookFilter,
						dlg.ExportWhat, dlg.BookNumber, dlg.FirstSection, dlg.LastSection,
						dlg.Description);
					string filename = Path.GetFileName(dlg.FileName);
					string directory = Path.GetDirectoryName(dlg.FileName);
					if (directory.EndsWith(Path.VolumeSeparatorChar.ToString()) &&
						!directory.EndsWith(Path.DirectorySeparatorChar.ToString()))
					{
						directory += Path.DirectorySeparatorChar.ToString();
					}
					export.FileName = Path.Combine(directory, filename);
					if (export.Run())
					{
						// Validate the XML file. If it doesn't pass validation, display a
						// yellow error message box.
						string strError = Validator.GetAnyValidationErrors(export.FileName);
						if (!String.IsNullOrEmpty(strError))
							throw new SIL.Utils.ContinuableErrorException(strError);
					}
				}
			}
			return true;
		}