Summary description for DummyFileMaker.
Inheritance: IFWDisposable
		public void TestTextRepOfObj_CmPicture()
		{
			string internalPathOrig = null;
			string internalPathNew = null;
			try
			{
				using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
				{
					ITsStrFactory factory = TsStrFactoryClass.Create();
					using (var editHelper = new RootSiteEditingHelper(Cache, null))
					{
						ICmPicture pict = Cache.ServiceLocator.GetInstance<ICmPictureFactory>().Create(
							filemaker.Filename, factory.MakeString("Test picture", Cache.DefaultVernWs),
							CmFolderTags.LocalPictures);
						Assert.IsNotNull(pict);
						Assert.IsTrue(pict.PictureFileRA.AbsoluteInternalPath == pict.PictureFileRA.InternalPath);
						string sTextRepOfObject = editHelper.TextRepOfObj(Cache, pict.Guid);
						int objectDataType;
						Guid guid = editHelper.MakeObjFromText(Cache, sTextRepOfObject, null,
							out objectDataType);
						ICmPicture pictNew = Cache.ServiceLocator.GetInstance<ICmPictureRepository>().GetObject(guid);
						Assert.IsTrue(pict != pictNew);
						internalPathOrig = pict.PictureFileRA.AbsoluteInternalPath;
						internalPathNew = pictNew.PictureFileRA.AbsoluteInternalPath;
						Assert.AreEqual(internalPathOrig, internalPathNew);
						Assert.AreEqual(internalPathOrig.IndexOf("junk"), internalPathNew.IndexOf("junk"));
						Assert.IsTrue(internalPathNew.EndsWith(".jpg"));
						AssertEx.AreTsStringsEqual(pict.Caption.VernacularDefaultWritingSystem,
							pictNew.Caption.VernacularDefaultWritingSystem);
						Assert.AreEqual(pict.PictureFileRA.Owner, pictNew.PictureFileRA.Owner);
					}
				}
			}
			finally
			{
				// TODO: When Undo works right, these should get cleaned up automatically
				if (internalPathOrig != null)
					File.Delete(internalPathOrig);
				if (internalPathNew != null)
					File.Delete(internalPathNew);
			}
		}
示例#2
0
		public void CreateOwnedObjects_Picture()
		{
			IStTxtPara para = m_currentText[0];

			ITsString tss = para.Contents;
			ITsStrFactory factory = Cache.TsStrFactory;
			using (DummyFileMaker fileMaker = new DummyFileMaker("junk.jpg", true))
			{
				ICmPicture pict = Cache.ServiceLocator.GetInstance<ICmPictureFactory>().Create(fileMaker.Filename,
					factory.MakeString("Test picture", Cache.DefaultVernWs),
					CmFolderTags.LocalPictures);
				para.Contents = pict.InsertORCAt(tss, 0);
				tss = para.Contents;
				int cchOrigStringLength = tss.Length;

				ReflectionHelper.CallMethod((IScrTxtPara)para, "CreateOwnedObjects", 0, 1);

				tss = para.Contents;
				Assert.AreEqual(cchOrigStringLength, tss.Length);
				string sObjData = tss.get_Properties(0).GetStrPropValue((int)FwTextPropType.ktptObjData);
				Guid guid = MiscUtils.GetGuidFromObjData(sObjData.Substring(1));

				byte odt = Convert.ToByte(sObjData[0]);
				Assert.AreEqual((byte)FwObjDataTypes.kodtGuidMoveableObjDisp, odt);
				Assert.IsTrue(pict.Guid != guid, "New guid was not inserted");
			}
		}
示例#3
0
		public void GetTextTokens_WholeBook()
		{
			ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
			m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis");
			int iExodus = 2;
			IScrBook exodus = m_scrInMemoryCache.AddBookToMockedScripture(iExodus, "Exodus");
			m_scrInMemoryCache.AddTitleToMockedBook(exodus.Hvo, "Exodus");

			IScrSection section = m_scrInMemoryCache.AddIntroSectionToMockedBook(exodus.Hvo);
			StTxtPara paraIntroSectHead = m_scrInMemoryCache.AddParaToMockedText(section.HeadingOAHvo,
				ScrStyleNames.IntroSectionHead);
			m_scrInMemoryCache.AddRunToMockedPara(paraIntroSectHead, "Everything you wanted to know about Exodus but were afraid to ask", null);
			StTxtPara paraIntroSectContent = m_scrInMemoryCache.AddParaToMockedText(section.ContentOAHvo,
				ScrStyleNames.IntroParagraph);
			m_scrInMemoryCache.AddRunToMockedPara(paraIntroSectContent, "There's not much to say, really.", null);
			section.AdjustReferences();

			section = m_scrInMemoryCache.AddSectionToMockedBook(exodus.Hvo);
			StTxtPara paraSectHead1 = m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Head1", ScrStyleNames.SectionHead);
			StTxtPara paraSect1Content = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect1Content, "1", ScrStyleNames.ChapterNumber);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect1Content, "1", ScrStyleNames.VerseNumber);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect1Content, "Chapter 1 Verse 1 Text", null);
			section.AdjustReferences();

			section = m_scrInMemoryCache.AddSectionToMockedBook(exodus.Hvo);
			StTxtPara paraSectHead2 = m_scrInMemoryCache.AddSectionHeadParaToSection(section.Hvo, "Head2", ScrStyleNames.SectionHead);
			StTxtPara paraSect2Content1 = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect2Content1, "2", ScrStyleNames.ChapterNumber);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect2Content1, "Chapter 2 Verse 1 Text", null);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect2Content1, "2", ScrStyleNames.VerseNumber);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect2Content1, "Chapter 2 Verse 2 Text ", null);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect2Content1, "Wow!", "Emphasis");
			StTxtPara paraSect2Content2 = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, "Line 1");
			m_scrInMemoryCache.AddRunToMockedPara(paraSect2Content2, "Selah", ScrStyleNames.Interlude);
			StFootnote footnote = m_scrInMemoryCache.AddFootnote(exodus, paraSect2Content2, 5, "This is the text of the footnote");
			m_scrInMemoryCache.AddRunToMockedPara((StTxtPara)footnote.ParagraphsOS[0], "Favorite", Cache.DefaultUserWs);
			m_scrInMemoryCache.AddRunToMockedPara(paraSect2Content2, " or say, \"la\".", null);
			CmPicture pict;
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				ITsStrFactory factory = TsStrFactoryClass.Create();
				pict = new CmPicture(Cache, filemaker.Filename,
					factory.MakeString("Test picture caption", Cache.DefaultVernWs),
					StringUtils.LocalPictures);
				ITsStrBldr bldr = paraSect2Content2.Contents.UnderlyingTsString.GetBldr();
				pict.AppendPicture(Cache.DefaultVernWs, bldr);
				paraSect2Content2.Contents.UnderlyingTsString = bldr.GetString();
			}
			section.AdjustReferences();

			Assert.IsTrue(dataSource.GetText(iExodus, 0));
			IEnumerator<ITextToken> tokens = dataSource.TextTokens().GetEnumerator();
			VerifyToken(tokens, "Exodus", ScrStyleNames.MainBookTitle, string.Empty, exodus.TitleOA.ParagraphsOS[0]);
			VerifyToken(tokens, "Everything you wanted to know about Exodus but were afraid to ask", ScrStyleNames.IntroSectionHead, string.Empty, paraIntroSectHead);
			VerifyToken(tokens, "There's not much to say, really.", ScrStyleNames.IntroParagraph, string.Empty, paraIntroSectContent);
			BCVRef expectedRef = new BCVRef(iExodus, 1, 1);
			VerifyToken(tokens, "Head1", ScrStyleNames.SectionHead, string.Empty, expectedRef, true, TextType.Other, paraSectHead1);
			VerifyToken(tokens, "1", ScrStyleNames.NormalParagraph, ScrStyleNames.ChapterNumber, expectedRef, true, TextType.ChapterNumber, paraSect1Content);
			VerifyToken(tokens, "1", ScrStyleNames.NormalParagraph, ScrStyleNames.VerseNumber, expectedRef, false, TextType.VerseNumber, paraSect1Content);
			VerifyToken(tokens, "Chapter 1 Verse 1 Text", "Paragraph", string.Empty, expectedRef, false, TextType.Verse, paraSect1Content);
			expectedRef.Chapter = 2;
			VerifyToken(tokens, "Head2", ScrStyleNames.SectionHead, string.Empty, expectedRef, true, TextType.Other, paraSectHead2);
			VerifyToken(tokens, "2", ScrStyleNames.NormalParagraph, ScrStyleNames.ChapterNumber, expectedRef, true, TextType.ChapterNumber, paraSect2Content1);
			VerifyToken(tokens, "Chapter 2 Verse 1 Text", ScrStyleNames.NormalParagraph, string.Empty, expectedRef, false, TextType.Verse, paraSect2Content1);
			expectedRef.Verse = 2;
			VerifyToken(tokens, "2", ScrStyleNames.NormalParagraph, ScrStyleNames.VerseNumber, expectedRef, false, TextType.VerseNumber, paraSect2Content1);
			VerifyToken(tokens, "Chapter 2 Verse 2 Text ", ScrStyleNames.NormalParagraph, string.Empty, expectedRef, false, TextType.Verse, paraSect2Content1);
			VerifyToken(tokens, "Wow!", ScrStyleNames.NormalParagraph, ScrStyleNames.Emphasis, expectedRef, false, TextType.Verse, paraSect2Content1);
			VerifyToken(tokens, "Selah", "Line 1", ScrStyleNames.Interlude, expectedRef, true, TextType.Verse, paraSect2Content2);
			VerifyToken(tokens, "This is the text of the footnote", ScrStyleNames.NormalFootnoteParagraph, string.Empty,
				expectedRef, true, TextType.Note, footnote.ParagraphsOS[0]);
			VerifyToken(tokens, "Favorite", ScrStyleNames.NormalFootnoteParagraph, string.Empty, expectedRef,
				expectedRef, false, TextType.Note, "en", footnote.ParagraphsOS[0], (int)StTxtPara.StTxtParaTags.kflidContents);
			VerifyToken(tokens, " or say, \"la\".", "Line 1", string.Empty, expectedRef, false, TextType.Verse, paraSect2Content2);
			VerifyToken(tokens, "Test picture caption", ScrStyleNames.Figure, string.Empty, expectedRef, expectedRef, true, TextType.PictureCaption, null,
				pict, (int)CmPicture.CmPictureTags.kflidCaption);
			Assert.IsFalse(tokens.MoveNext());
		}
示例#4
0
		public void HandleUSFMStylePicturesWithBT()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				m_importer.Settings.ImportBackTranslation = true;

				// initialize - process a \id segment to establish a book
				m_importer.TextSegment.FirstReference = new BCVRef(2, 0, 0);
				m_importer.TextSegment.LastReference = new BCVRef(2, 0, 0);
				m_importer.ProcessSegment("", @"\id");

				// ******** test a picture
				m_importer.TextSegment.FirstReference = new BCVRef(2, 1, 0);
				m_importer.TextSegment.LastReference = new BCVRef(2, 1, 0);
				m_importer.ProcessSegment("", @"\c");
				m_importer.ProcessSegment("", @"\p");
				m_importer.ProcessSegment("User-supplied picture|" + filemaker.Filename +
					"|col|EXO 1--1||Caption for junk.jpg|", @"\fig");
				m_importer.ProcessSegment("back translation for junk.jpg", @"\btfig");
				m_importer.FinalizeImport();
				IScrBook exodus = m_importer.UndoInfo.ImportedVersion.BooksOS[0];
				IScrSection section = exodus.SectionsOS[0];
				IStTxtPara para = (IStTxtPara)section.ContentOA.ParagraphsOS[0];

				Assert.AreEqual("1" + StringUtils.kChObject.ToString(),
					para.Contents.Text);
				ITsString tss = para.Contents;
				Assert.AreEqual(2, tss.RunCount);
				string sObjData = tss.get_Properties(1).GetStrPropValue((int)FwTextPropType.ktptObjData);
				Guid guid = MiscUtils.GetGuidFromObjData(sObjData.Substring(1));
				ICmPicture picture = Cache.ServiceLocator.GetInstance<ICmPictureRepository>().GetObject(guid);
				try
				{
					Assert.AreEqual("Caption for junk.jpg", picture.Caption.VernacularDefaultWritingSystem.Text);
					Assert.IsTrue(picture.PictureFileRA.InternalPath == picture.PictureFileRA.AbsoluteInternalPath);
					Assert.IsTrue(picture.PictureFileRA.InternalPath.IndexOf("junk") >= 0);
					Assert.IsTrue(picture.PictureFileRA.InternalPath.EndsWith(".jpg"));
					byte odt = Convert.ToByte(sObjData[0]);
					Assert.AreEqual((byte)FwObjDataTypes.kodtGuidMoveableObjDisp, odt);
					Assert.AreEqual(Path.Combine(Path.GetTempPath(), "back translation for junk.jpg"),
						picture.Caption.get_String(DefaultAnalWs).Text);
				}
				finally
				{
					if (picture != null)
					{
						FileUtils.Delete(Path.Combine(FwDirectoryFinder.DataDirectory,
							picture.PictureFileRA.InternalPath));
					}
				}
			}
		}
示例#5
0
		public void HandleToolboxStylePictures_CatAfterCat()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				// initialize - process a \id segment to establish a book
				m_importer.TextSegment.FirstReference = new BCVRef(2, 0, 0);
				m_importer.TextSegment.LastReference = new BCVRef(2, 0, 0);
				m_importer.ProcessSegment("", @"\id");

				// ******** test a picture
				m_importer.TextSegment.FirstReference = new BCVRef(2, 1, 0);
				m_importer.TextSegment.LastReference = new BCVRef(2, 1, 0);
				m_importer.ProcessSegment("", @"\c");
				m_importer.ProcessSegment("", @"\p");
				m_importer.ProcessSegment(filemaker.Filename, @"\cat");
				string fileName = MiscUtils.IsUnix ? "/MissingPicture.jpg" : @"c:\MissingPicture.jpg";
				m_importer.ProcessSegment(fileName, @"\cat");
				m_importer.FinalizeImport();
				IScrBook exodus = m_importer.UndoInfo.ImportedVersion.BooksOS[0];
				IScrSection section = exodus.SectionsOS[0];
				IStTxtPara para = (IStTxtPara)section.ContentOA.ParagraphsOS[0];

				Assert.AreEqual("1" + StringUtils.kChObject.ToString() + StringUtils.kChObject.ToString(),
					para.Contents.Text);
				ITsString tss = para.Contents;
				Assert.AreEqual(3, tss.RunCount);
				string sObjData = tss.get_Properties(1).GetStrPropValue((int)FwTextPropType.ktptObjData);
				Guid guid = MiscUtils.GetGuidFromObjData(sObjData.Substring(1));
				ICmPicture picture = Cache.ServiceLocator.GetInstance<ICmPictureRepository>().GetObject(guid);
				try
				{
					Assert.IsNull(picture.Caption.VernacularDefaultWritingSystem.Text);
					Assert.IsTrue(picture.PictureFileRA.InternalPath == picture.PictureFileRA.AbsoluteInternalPath);
					Assert.IsTrue(picture.PictureFileRA.InternalPath.IndexOf("junk") >= 0);
					Assert.IsTrue(picture.PictureFileRA.InternalPath.EndsWith(".jpg"));
					byte odt = Convert.ToByte(sObjData[0]);
					Assert.AreEqual((byte)FwObjDataTypes.kodtGuidMoveableObjDisp, odt);
					Assert.IsNull(picture.Description.AnalysisDefaultWritingSystem.Text);
					Assert.AreEqual(PictureLayoutPosition.CenterInColumn, picture.LayoutPos);
					Assert.AreEqual(100, picture.ScaleFactor);
					Assert.AreEqual(PictureLocationRangeType.AfterAnchor, picture.LocationRangeType);
					Assert.IsNull(picture.PictureFileRA.Copyright.VernacularDefaultWritingSystem.Text);
				}
				finally
				{
					if (picture != null)
					{
						FileUtils.Delete(picture.PictureFileRA.AbsoluteInternalPath);
					}
				}

				// Make sure the second picture (the missing one) is okay
				sObjData = tss.get_Properties(2).GetStrPropValue((int)FwTextPropType.ktptObjData);
				guid = MiscUtils.GetGuidFromObjData(sObjData.Substring(1));
				picture = Cache.ServiceLocator.GetInstance<ICmPictureRepository>().GetObject(guid);
				Assert.IsNull(picture.Caption.VernacularDefaultWritingSystem.Text);
				Assert.IsTrue(picture.PictureFileRA.InternalPath == picture.PictureFileRA.AbsoluteInternalPath);
				Assert.AreEqual(fileName, picture.PictureFileRA.InternalPath);
				Assert.AreEqual((byte)FwObjDataTypes.kodtGuidMoveableObjDisp, Convert.ToByte(sObjData[0]));
				Assert.IsNull(picture.Description.AnalysisDefaultWritingSystem.Text);
				Assert.AreEqual(PictureLayoutPosition.CenterInColumn, picture.LayoutPos);
				Assert.AreEqual(100, picture.ScaleFactor);
				Assert.AreEqual(PictureLocationRangeType.AfterAnchor, picture.LocationRangeType);
				Assert.IsNull(picture.PictureFileRA.Copyright.VernacularDefaultWritingSystem.Text);
			}
		}
示例#6
0
		public void EnsurePictureFilePathIsRooted_RootedButNoDriveLetter_FoundRelativeToCurrentDrive()
		{
			DummyScrObjWrapper sow = (DummyScrObjWrapper)ReflectionHelper.GetProperty(m_importer, "SOWrapper");
			sow.m_fIncludeMyPicturesFolderInExternalFolders = true;

			using (DummyFileMaker filemaker = new DummyFileMaker(Path.Combine(Path.GetPathRoot(Environment.CurrentDirectory), "j~u~n~k.jpg"), false))
			{
				String str1 = "P0|" + filemaker.Filename + "|P2|P3|P4";
				String str2 = ReflectionHelper.GetStrResult(m_importer, "EnsurePictureFilePathIsRooted", @"P0|\j~u~n~k.jpg|P2|P3|P4");
				Assert.AreEqual(str1.ToLowerInvariant(), str2.ToLowerInvariant());
			}
		}
		public void CreateNewLangProject_DbFilesExist()
		{
			DummyFwNewLangProjectCreator creator = new DummyFwNewLangProjectCreator();

			// Setup: Create "pre-existing" DB filenames
			using (
				DummyFileMaker existingDB =
					new DummyFileMaker(DirectoryFinder.DataDirectory + @"\Gumby.mdf"),
					existingDB2 =
					new DummyFileMaker(DirectoryFinder.DataDirectory + @"\Gumby2.mdf"),
					existingLogFile =
					new DummyFileMaker(DirectoryFinder.DataDirectory + @"\Gumby_log.ldf"),
					existingLogFile1 =
					new DummyFileMaker(DirectoryFinder.DataDirectory + @"\Gumby1_log.ldf"))
			{
				List<string> preExistingFiles =
					new List<string>(Directory.GetFiles(DirectoryFinder.DataDirectory));
				List<string> postExistingFiles = null;

				try
				{
					string sNewDbFileName;
					string sNewLogFileName;
					creator.CallCreateNewDbFiles("Gumby", out sNewDbFileName, out sNewLogFileName);

					postExistingFiles =
						new List<string>(Directory.GetFiles(DirectoryFinder.DataDirectory));

					Assert.AreEqual(DirectoryFinder.DataDirectory + @"\Gumby3.mdf", sNewDbFileName);
					Assert.AreEqual(DirectoryFinder.DataDirectory + @"\Gumby3_log.ldf", sNewLogFileName);

					Assert.IsTrue(File.Exists(sNewDbFileName));
					Assert.IsTrue(File.Exists(sNewLogFileName));
					Assert.AreEqual(preExistingFiles.Count + 2, postExistingFiles.Count);
				}
				finally
				{
					// Blow away the files to clean things up
					if (postExistingFiles == null)
					{
						postExistingFiles =
							new List<string>(Directory.GetFiles(DirectoryFinder.DataDirectory));
					}
					foreach (string fileName in postExistingFiles)
					{
						try
						{
							if (!preExistingFiles.Contains(fileName))
								File.Delete(fileName);
						}
						catch
						{
						}
					}
				}
			}
		}
示例#8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a picture (no caption set).
		/// </summary>
		/// <param name="para">Paragraph to insert picture into</param>
		/// <param name="ichPos">The 0-based character offset into the paragraph</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected ICmPicture InsertTestPicture(IStTxtPara para, int ichPos)
		{
			ICmPicture pict;
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				ITsStrFactory factory = TsStrFactoryClass.Create();
				pict = Cache.ServiceLocator.GetInstance<ICmPictureFactory>().Create(filemaker.Filename,
					factory.MakeString("Test picture caption", Cache.DefaultVernWs),
					CmFolderTags.LocalPictures);
				ITsStrBldr bldr = para.Contents.GetBldr();
				pict.InsertORCAt(bldr, ichPos);
				para.Contents = bldr.GetString();
			}

			return pict;
		}
示例#9
0
		public void Annotation_Toolbox_PartialMatchInVerseBridge_ParaAfter()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para;

				para = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\v1-3\*In the beginning", m_wsVern,
					ScrStyleNames.NormalParagraph);
				ExportHelper.AddAnnotation(this, "Note on verse 3", new ScrReference(1, 1, 3, m_scr.Versification), para);
				para = ExportHelper.AppendParagraph(this, m_book, section, @"\*God created stuff\v5\*More text",
					m_wsVern, ScrStyleNames.NormalParagraph);

				// export
				m_exporter.MarkupSystem = MarkupType.Toolbox;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportSection(section, false);

				// we expect that the note is output just after the first paragraph because
				// the note refers to a verse within the verse bridge, and
				// the note hvo matches the paragraph hvo.
				string[] expected = new string[] {@"\rcrd GEN 1", @"\c 1",
													 @"\s My section head", @"\p",
													 @"\vref GEN.1:1",
													 @"\v 1-3", @"\vt In the beginning",
													 @"\rem Note on verse 3",
													 @"\p",
													 @"\vt God created stuff",
													 @"\vref GEN.1:5",
													 @"\v 5", @"\vt More text"};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#10
0
		public void Annotation_Paratext_ParaSameVerseContinuesAfter()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para;

				para = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\v1\*In the beginning", m_wsVern,
					ScrStyleNames.NormalParagraph);
				ExportHelper.AddAnnotation(this, "Note for verse 1a", new ScrReference(1, 1, 1, m_scr.Versification), para);

				para = ExportHelper.AppendParagraph(this, m_book, section, @"\*God created stuff\v2\*More text",
					m_wsVern, ScrStyleNames.NormalParagraph);
				ExportHelper.AddAnnotation(this, "Note for verse 1b", new ScrReference(1, 1, 1, m_scr.Versification), para);
				ExportHelper.AddAnnotation(this, "Note for verse 2", new ScrReference(1, 1, 2, m_scr.Versification), para);

				// export
				m_exporter.MarkupSystem = MarkupType.Paratext;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportSection(section, false);

				// we expect that the note is output just after the first paragraph because
				// the note hvo matches the paragraph hvo.
				string[] expected = new string[]
					{
						@"\c 1",
						@"\s My section head", @"\p",
						@"\v 1 In the beginning",
						@"\rem Note for verse 1a",
						@"\p God created stuff",
						@"\rem Note for verse 1b",
						@"\v 2 More text",
						@"\rem Note for verse 2"
				};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#11
0
		public void Annotation_Toolbox_SectionHead_NonContiguousVerses()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head"); //creates section head para 1
				IStTxtPara para2Head = ExportHelper.AppendParagraphToSectionHead(this, m_book, section,
					@"\*Second paragraph of section head",
					m_wsVern, ScrStyleNames.SectionHead);
				ExportHelper.AddAnnotation(this, "Section head annotation 1", new ScrReference(1, 2, 1, m_scr.Versification), //section.AdjustRefs finds that start ref is C2 V1
					section.HeadingOA.ParagraphsOS[0]);
				ExportHelper.AddAnnotation(this, "Section head annotation 2", new ScrReference(1, 2, 1, m_scr.Versification), //section.AdjustRefs finds that start ref is C2 V1
					para2Head);

				IStTxtPara para;
				para = ExportHelper.AppendParagraph(this, m_book, section, @"\c2\v5\*When the LORD made...", m_wsVern, // not C1 V1
					ScrStyleNames.NormalParagraph);
				para = ExportHelper.AppendParagraph(this, m_book, section, @"\v18\*It is not good for the man to be alone.", m_wsVern,
					ScrStyleNames.NormalParagraph);
				// use wrong para to test ref matching of annotation
				ExportHelper.AddAnnotation(this, "Annotation for C2 V5", new ScrReference(1, 2, 5, m_scr.Versification), para);

				para = ExportHelper.AppendParagraph(this, m_book, section, @"\c6\*When mankind began to increase", m_wsVern,
					ScrStyleNames.NormalParagraph);
				// use wrong para to test ref matching of annotation
				ExportHelper.AddAnnotation(this, "Annotation for C2 V18", new ScrReference(1, 2, 18, m_scr.Versification), para);

				// export
				m_exporter.MarkupSystem = MarkupType.Toolbox;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportSection(section, false);

				// we expect that the note is output before the new paragraph with new chapter
				string[] expected = new string[]
					{
						@"\rcrd GEN 2", @"\c 2",
						@"\s My section head",
						@"\rem Section head annotation 1",
						@"\s Second paragraph of section head",
						@"\rem Section head annotation 2",
						@"\p",
						@"\vref GEN.2:5",
						@"\v 5", @"\vt When the LORD made...",
						@"\rem Annotation for C2 V5",
						@"\p",
						@"\vref GEN.2:18",
						@"\v 18", @"\vt It is not good for the man to be alone.",
						@"\rem Annotation for C2 V18",
						@"\rcrd GEN 6", @"\c 6",
						@"\p",
						@"\vref GEN.6:1",
						@"\v 1", @"\vt When mankind began to increase"
					};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#12
0
		public void Annotation_Paratext_ChapterAfter()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para;

				para = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\v1\*In the beginning\c2\v1\*God created stuff",
					m_wsVern, ScrStyleNames.NormalParagraph);
				ExportHelper.AddAnnotation(this, "Here's an annotation.", new ScrReference(1, 1, 1, m_scr.Versification), para);

				ITsString tss = para.Contents;
				Assert.AreEqual(6, tss.RunCount);

				// export
				m_exporter.MarkupSystem = MarkupType.Paratext;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportParagraph(para);

				// we expect the annotation to follow the verse it references
				string[] expected = new string[] {@"\c 1", @"\p",
													 @"\v 1 In the beginning",
													 @"\rem Here's an annotation.",
													 @"\c 2",
													 @"\v 1 God created stuff"};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#13
0
		public void Annotation_Toolbox_VerseBridge_VerseAfter()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para;

				para = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\v1-2\*In the beginning\v3\*God created stuff",
					m_wsVern, ScrStyleNames.NormalParagraph);
				ExportHelper.AddAnnotation(this, "Here's an annotation.",
					new ScrReference(1, 1, 1, m_scr.Versification), new ScrReference(1, 1, 2, m_scr.Versification), para, para);

				// export
				m_exporter.MarkupSystem = MarkupType.Toolbox;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportParagraph(para);

				// we expect the annotation to follow the verse it references
				string[] expected = new string[] {@"\rcrd GEN 1", @"\c 1", @"\p",
													 @"\vref GEN.1:1",
													 @"\v 1-2", @"\vt In the beginning",
													 @"\rem Here's an annotation.",
													 @"\vref GEN.1:3",
													 @"\v 3", @"\vt God created stuff"};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets up and verifies that usfm and toolbox exported scriptures do not include
		/// references with checking error annotations.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void VerifyOutputForRefWithCheckingError(MarkupType type, string source,
			string[] expected)
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section =
					ExportHelper.CreateSection(this, m_book, "My section head");

				IScrTxtPara para = ExportHelper.AppendParagraph(this,
					m_book, section, source, m_wsVern, ScrStyleNames.NormalParagraph);

				AddAnnotation(para, new BCVRef(1001001), NoteType.CheckingError);

				// export
				m_exporter.MarkupSystem = type;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportParagraph(para);
				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#15
0
		public void CreateOwnedObjects_Picture()
		{
			CheckDisposed();

			StTxtPara para = (StTxtPara)m_currentText.ParagraphsOS[0];

			ITsString tss = para.Contents.UnderlyingTsString;
			ITsStrFactory factory = TsStrFactoryClass.Create();
			using (DummyFileMaker fileMaker = new DummyFileMaker("junk.jpg", true))
			{
				CmPicture pict = new CmPicture(Cache, fileMaker.Filename,
					factory.MakeString("Test picture", Cache.DefaultVernWs),
					StringUtils.LocalPictures);
				pict.InsertORCAt(tss, 0, para.Hvo,
					(int)StTxtPara.StTxtParaTags.kflidContents, 0);
				tss = para.Contents.UnderlyingTsString;
				int cchOrigStringLength = tss.Length;

				NMock.DynamicMock mockIObjectMetaInfoProvider =
					new DynamicMock(typeof(IObjectMetaInfoProvider));
				mockIObjectMetaInfoProvider.Strict = true;
				mockIObjectMetaInfoProvider.ExpectAndReturn(1, "PictureFolder", StringUtils.LocalPictures);
				para.CreateOwnedObjects(0, 1,
					(IObjectMetaInfoProvider)mockIObjectMetaInfoProvider.MockInstance);
				mockIObjectMetaInfoProvider.Verify();

				tss = para.Contents.UnderlyingTsString;
				Assert.AreEqual(cchOrigStringLength, tss.Length);
				string sObjData = tss.get_Properties(0).GetStrPropValue((int)FwTextPropType.ktptObjData);
				Guid guid = MiscUtils.GetGuidFromObjData(sObjData.Substring(1));

				byte odt = Convert.ToByte(sObjData[0]);
				Assert.AreEqual((byte)FwObjDataTypes.kodtGuidMoveableObjDisp, odt);
				Assert.IsTrue(Cache.GetGuidFromId(pict.Hvo) != guid, "New guid was not inserted");
			}
		}
示例#16
0
		public void ExportPara_Toolbox_PictureWithBT()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para;

				ReflectionHelper.SetField(m_exporter, "m_currentBookAbbrev", "Gine.");

				para = ExportHelper.AppendParagraph(this, m_book, section,
					@"\c1\v1\iCmPicture|User-supplied picture|" + filemaker.Filename
					+ @"|col|GEN 1--2||My favorite caption||\^", m_wsVern, ScrStyleNames.NormalParagraph);
				// find the picture that was created in the paragraph
				ICmPicture picture = para.GetPictures()[0];
				picture.Caption.set_String(m_wsEnglish, TsStringUtils.MakeTss("Cool", m_wsEnglish));
				picture.Caption.set_String(m_wsGerman, TsStringUtils.MakeTss("Mein favorite Martian caption", m_wsGerman));
				picture.Caption.set_String(m_wsSpanish, TsStringUtils.MakeTss("Mino favorita Martiana captionia", m_wsSpanish));
				string sInternalAbsPath = picture.PictureFileRA.AbsoluteInternalPath;

				try
				{
					// export
					m_exporter.MarkupSystem = MarkupType.Toolbox;
					m_exporter.ExportScriptureDomain = true;
					m_exporter.ExportBackTranslationDomain = true;
					m_exporter.RequestedAnalysisWss = new int[] { m_wsEnglish,
						m_wsGerman, m_wsSpanish };
					m_exporter.ExportParagraph(para);

					string[] expected = new string[]
					{
						@"\rcrd GEN 1", @"\c 1", @"\p",
						@"\vref GEN.1:1",
						@"\v 1",
						@"\figdesc User-supplied picture", @"\figcat " + sInternalAbsPath,
						@"\figlaypos col", @"\figrefrng GEN 1:1-GEN 2:25", @"\figcap My favorite caption",
// TODO (TE-7759)						+ "|ReferenceRange|100",
						@"\figscale 100",
						@"\btfigcap Cool",
						@"\btfigcap_de Mein favorite Martian caption",
						@"\btfigcap_es Mino favorita Martiana captionia",
					};

					m_exporter.FileWriter.VerifyOutput(expected);
				}
				finally
				{
					if (picture != null)
						File.Delete(sInternalAbsPath);
				}
			}
		}
示例#17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Sets up current and revision paragraphs, inserting a picture in the specified
		/// paragraph. This returns the position where the picture was inserted.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private int SetupPictureDiffTests(bool putPicInRev, out StTxtPara paraCur,
			out StTxtPara paraRev)
		{
			// create Current section
			IScrSection sectionCur = CreateSection(m_genesis, "My aching head!");
			paraCur = m_scrInMemoryCache.AddParaToMockedSectionContent(sectionCur.Hvo, ScrStyleNames.NormalParagraph);
			m_scrInMemoryCache.AddRunToMockedPara(paraCur, "1", ScrStyleNames.ChapterNumber);
			m_scrInMemoryCache.AddRunToMockedPara(paraCur, "Hello.", Cache.DefaultVernWs);

			// create Revision section
			IScrSection sectionRev = CreateSection(m_genesisRevision, "My aching head!");
			paraRev = m_scrInMemoryCache.AddParaToMockedSectionContent(sectionRev.Hvo, ScrStyleNames.NormalParagraph);
			m_scrInMemoryCache.AddRunToMockedPara(paraRev, "1", ScrStyleNames.ChapterNumber);
			m_scrInMemoryCache.AddRunToMockedPara(paraRev, "Hello.", Cache.DefaultVernWs);

			int picPos = 7;
			StTxtPara para = (putPicInRev ? paraRev : paraCur);
			ITsString tss = para.Contents.UnderlyingTsString;

			// Add picture to revision.
			ITsStrFactory factory = TsStrFactoryClass.Create();
			using (DummyFileMaker fileMaker = new DummyFileMaker("junk.jpg", true))
			{
				CmPicture pict = new CmPicture(Cache, fileMaker.Filename,
					factory.MakeString("Test picture", Cache.DefaultVernWs),
					StringUtils.LocalPictures);

				pict.InsertORCAt(tss, picPos, para.Hvo,
					(int)StTxtPara.StTxtParaTags.kflidContents, 0);
			}

			m_bookMerger.DetectDifferences(null);
			Assert.AreEqual(1, m_bookMerger.Differences.Count);
			return picPos;
		}
示例#18
0
		public void Annotation_Toolbox_MultiPara_ParaAfter()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para1, para2, para3;

				para1 = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\v3\*In the beginning", m_wsVern,
					ScrStyleNames.NormalParagraph);
				para2 = ExportHelper.AppendParagraph(this, m_book, section, @"\*God created stuff",
					m_wsVern, ScrStyleNames.NormalParagraph);
				para3 = ExportHelper.AppendParagraph(this, m_book, section, @"\*More text",
					m_wsVern, ScrStyleNames.NormalParagraph);

				ExportHelper.AddAnnotation(this, "Here's an annotation.",
					new ScrReference(1, 1, 3, m_scr.Versification), new ScrReference(1, 1, 3, m_scr.Versification), para1, para2);

				// export
				m_exporter.MarkupSystem = MarkupType.Toolbox;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportSection(section, false);

				// For now, we expect that the note is output just after the first paragraph
				// it refers to.
				// TODO: When import/export supports notes for multiple paragraphs, we'll need
				// to export that relevant information
				string[] expected = new string[] {@"\rcrd GEN 1", @"\c 1",
													 @"\s My section head", @"\p",
													 @"\vref GEN.1:3",
													 @"\v 3", @"\vt In the beginning",
													 @"\rem Here's an annotation.",
													 @"\p",
													 @"\vt God created stuff",
													 @"\p",
													 @"\vt More text"};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#19
0
		public void TestTextRepOfObj_CmPicture()
		{
			CheckDisposed();

			string internalPathOrig = null;
			string internalPathNew = null;
			try
			{
				using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
				{
					ITsStrFactory factory = TsStrFactoryClass.Create();
					EditingHelper editHelper = new EditingHelper(null);
					CmPicture pict = new CmPicture(m_fdoCache, filemaker.Filename,
						factory.MakeString("Test picture", m_fdoCache.DefaultVernWs),
						StringUtils.LocalPictures);
					Assert.IsNotNull(pict);
					Assert.IsTrue(pict.PictureFileRA.AbsoluteInternalPath == pict.PictureFileRA.InternalPath);
					Guid guid = Cache.GetGuidFromId(pict.Hvo);
					string sTextRepOfObject = editHelper.TextRepOfObj(m_fdoCache, guid);
					int objectDataType;
					guid = editHelper.MakeObjFromText(m_fdoCache, sTextRepOfObject, null,
						out objectDataType);
					CmPicture pictNew = new CmPicture(Cache, Cache.GetIdFromGuid(guid));
					Assert.IsTrue(pict != pictNew);
					internalPathOrig = pict.PictureFileRA.AbsoluteInternalPath;
					internalPathNew = pictNew.PictureFileRA.AbsoluteInternalPath;
					Assert.AreEqual(internalPathOrig, internalPathNew);
					Assert.AreEqual(internalPathOrig.IndexOf("junk"), internalPathNew.IndexOf("junk"));
					Assert.IsTrue(internalPathNew.EndsWith(".jpg"));
					AssertEx.AreTsStringsEqual(pict.Caption.VernacularDefaultWritingSystem.UnderlyingTsString,
						pictNew.Caption.VernacularDefaultWritingSystem.UnderlyingTsString);
					Assert.AreEqual(pict.PictureFileRA.OwnerHVO, pictNew.PictureFileRA.OwnerHVO);
				}
			}
			finally
			{
				// TODO: When Undo works right, these should get cleaned up automatically
				if (internalPathOrig != null)
					File.Delete(internalPathOrig);
				if (internalPathNew != null)
					File.Delete(internalPathNew);
			}
		}
示例#20
0
		public void Annotation_Toolbox_WrongHvo()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para1, para2, para3;

				para1 = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\v1\*In the beginning", m_wsVern,
					ScrStyleNames.NormalParagraph);

				para2 = ExportHelper.AppendParagraph(this, m_book, section, @"\*God created stuff\v2\*More text",
					m_wsVern, ScrStyleNames.NormalParagraph);

				para3 = ExportHelper.AppendParagraph(this, m_book, section, @"\v3\*Even more text", m_wsVern,
					ScrStyleNames.NormalParagraph);

				// Make an annotation for verse one, but with the wrong hvo.
				ExportHelper.AddAnnotation(this, "Here's an annotation.", new ScrReference(1, 1, 1, m_scr.Versification), para3);

				// export
				m_exporter.MarkupSystem = MarkupType.Toolbox;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportSection(section, false);

				// we expect that the note is output at the end of verse 1, in spite of the wrong hvo
				string[] expected = new string[] {@"\rcrd GEN 1", @"\c 1",
													 @"\s My section head", @"\p",
													 @"\vref GEN.1:1",
													 @"\v 1", @"\vt In the beginning",
													 @"\p",
													 @"\vt God created stuff",
													 @"\rem Here's an annotation.",
													 @"\vref GEN.1:2",
													 @"\v 2", @"\vt More text",
													 @"\p",
													 @"\vref GEN.1:3",
													 @"\v 3", @"\vt Even more text" };

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#21
0
		public void EnsurePictureFilePathIsRooted_NotRooted_FoundInSecondExternalFolder()
		{
			DummyScrObjWrapper sow = (DummyScrObjWrapper)ReflectionHelper.GetProperty(m_importer, "SOWrapper");
			sow.m_fIncludeMyPicturesFolderInExternalFolders = true;
			if (sow.ExternalPictureFolders.Count < 2)
				Assert.Ignore("Test requires My Pictures folder to be set.");

			using (DummyFileMaker filemaker = new DummyFileMaker(Path.Combine(sow.ExternalPictureFolders[1], "j~u~n~k.jpg"), false))
			{
				Assert.IsTrue(Path.IsPathRooted(filemaker.Filename));
				Assert.AreEqual("P0|" + filemaker.Filename + "|P2|P3|P4",
					ReflectionHelper.GetStrResult(m_importer, "EnsurePictureFilePathIsRooted", "P0|j~u~n~k.jpg|P2|P3|P4"));
			}
		}
示例#22
0
		public void Annotation_Toolbox_ParaInvalidVerseAfter()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para;
				para = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\v1\*In the beginning", m_wsVern,
					ScrStyleNames.NormalParagraph);
				ExportHelper.AddAnnotation(this, "Here's an annotation.", new ScrReference(1, 1, 1, m_scr.Versification), para);

				para = ExportHelper.AppendParagraph(this, m_book, section, @"\vtwo\*God created stuff", m_wsVern,
					ScrStyleNames.NormalParagraph);

				// export
				m_exporter.MarkupSystem = MarkupType.Toolbox;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportSection(section, false);

				// we expect that the note is output before the new paragraph with invalid verse number
				string[] expected = new string[]
				{
					@"\rcrd GEN 1", @"\c 1",
					@"\s My section head",
					@"\p",
					@"\vref GEN.1:1",
					@"\v 1", @"\vt In the beginning",
					@"\rem Here's an annotation.",
					@"\p",
					@"\vref GEN.1:0",
					@"\v two", @"\vt God created stuff",
				};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#23
0
		public void EnsurePictureFilePathIsRooted_RootedButNoDriveLetter_FoundInFirstExternalFolder()
		{
			DummyScrObjWrapper sow = (DummyScrObjWrapper)ReflectionHelper.GetProperty(m_importer, "SOWrapper");
			sow.m_fIncludeMyPicturesFolderInExternalFolders = true;

			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				Assert.AreEqual("P0|" + filemaker.Filename + "|P2|P3|P4",
					ReflectionHelper.GetStrResult(m_importer, "EnsurePictureFilePathIsRooted", @"P0|\junk.jpg|P2|P3|P4"));
			}
		}
示例#24
0
		public void Annotation_Toolbox_VerseOutOfOrder()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");

				IStTxtPara para1 = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\v1\*In the beginning\v4-5\*God created\v3\*stuff",
					m_wsVern, ScrStyleNames.NormalParagraph);
				IStTxtPara para2 = ExportHelper.AppendParagraph(this, m_book, section, @"\v7\*verse seven",
					m_wsVern, ScrStyleNames.NormalParagraph);

				ExportHelper.AddAnnotation(this, "Note for verse 1", new ScrReference(1, 1, 1, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for verse 2", new ScrReference(1, 1, 2, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for verse 3", new ScrReference(1, 1, 3, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for verse 4", new ScrReference(1, 1, 4, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for verse 5", new ScrReference(1, 1, 5, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for verse 6", new ScrReference(1, 1, 6, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for verse 7", new ScrReference(1, 1, 7, m_scr.Versification), para2);

				// export
				m_exporter.MarkupSystem = MarkupType.Toolbox;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportSection(section, true);

				// We expect that the annotations for verses 2 and 3 will be output before verse 4,
				// and with verse markers.
				// The annotations for verse 6 will be output before the paragraph of verse 7.
				//  Ideally, the annotations would be output closer to the verse
				// they are associated with... but in this case, the verses are out of order.
				string[] expected = new string[]
					{
						@"\rcrd GEN 1", @"\c 1",
						@"\s My section head",
						@"\p",
						@"\vref GEN.1:1",
						@"\v 1", @"\vt In the beginning",
						@"\rem Note for verse 1",

						@"\vref GEN.1:2",
						@"\v 2",
						@"\rem Note for verse 2",
						@"\vref GEN.1:3",
						@"\v 3",
						@"\rem Note for verse 3",
						@"\vref GEN.1:4",
						@"\v 4-5", @"\vt God created",
						@"\rem Note for verse 4",
						@"\rem Note for verse 5",

						@"\vref GEN.1:3",
						@"\v 3", @"\vt stuff",

						@"\vref GEN.1:6",
						@"\v 6",
						@"\rem Note for verse 6",
						@"\p",
						@"\vref GEN.1:7",
						@"\v 7", @"\vt verse seven",
						@"\rem Note for verse 7",

					};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#25
0
		public void HandleToolboxStylePictures_InvalidFigFilename()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				// initialize - process a \id segment to establish a book
				m_importer.TextSegment.FirstReference = new BCVRef(2, 0, 0);
				m_importer.TextSegment.LastReference = new BCVRef(2, 0, 0);
				m_importer.ProcessSegment("", @"\id");

				// ******** test a picture
				m_importer.TextSegment.FirstReference = new BCVRef(2, 1, 0);
				m_importer.TextSegment.LastReference = new BCVRef(2, 1, 0);
				m_importer.ProcessSegment("", @"\c");
				m_importer.ProcessSegment("", @"\p");

				// Linux Invalid filename chars are only null and /,
				m_importer.ProcessSegment(MiscUtils.IsUnix ? "InvalidFile|junk\u0000jpg||" : "InvalidFile|.jpg||",
					@"\cat");
			}
		}
示例#26
0
		public void Annotation_Toolbox_ChapterOutOfOrder()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");

				IStTxtPara para1 = ExportHelper.AppendParagraph(this, m_book, section, @"\c1\*One\c4\*Four\c3\*Three",
					m_wsVern, ScrStyleNames.NormalParagraph);
				IStTxtPara para2 = ExportHelper.AppendParagraph(this, m_book, section, @"\c6\*Six",
					m_wsVern, ScrStyleNames.NormalParagraph);

				ExportHelper.AddAnnotation(this, "Note for chapter 1", new ScrReference(1, 1, 1, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for chapter 2", new ScrReference(1, 2, 1, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for chapter 3", new ScrReference(1, 3, 1, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for chapter 4", new ScrReference(1, 4, 1, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for chapter 5", new ScrReference(1, 5, 1, m_scr.Versification), para1);
				ExportHelper.AddAnnotation(this, "Note for chapter 6", new ScrReference(1, 6, 1, m_scr.Versification), para2);

				// export
				m_exporter.MarkupSystem = MarkupType.Toolbox;
				m_exporter.ExportScriptureDomain = true;
				m_exporter.ExportBackTranslationDomain = false;
				m_exporter.ExportNotesDomain = true;
				m_exporter.ExportSection(section, true);

				// We expect that the annotations for chapters 2 and 3 will be output before chapter 4,
				//  and with chapter markers.
				// The annotation for chapter 5 will be output before the paragraph for chapter 6.
				// Ideally, the annotations would be output closer to the chapter+verse
				// they are associated with... but in this case, the chapters are out of order.
				string[] expected = new string[]
				{
					@"\rcrd GEN 1", @"\c 1",
					@"\s My section head",
					@"\p",
					@"\vref GEN.1:1",
					@"\v 1", @"\vt One",
					@"\rem Note for chapter 1",

					@"\rcrd GEN 2", @"\c 2",
					@"\vref GEN.2:1",
					@"\v 1",
					@"\rem Note for chapter 2",
					@"\rcrd GEN 3", @"\c 3",
					@"\vref GEN.3:1",
					@"\v 1",
					@"\rem Note for chapter 3",
					@"\rcrd GEN 4", @"\c 4",
					@"\vref GEN.4:1",
					@"\v 1", @"\vt Four",
					@"\rem Note for chapter 4",

					@"\rcrd GEN 3", @"\c 3",
					@"\vref GEN.3:1",
					@"\v 1", @"\vt Three",

					@"\rcrd GEN 5", @"\c 5",
					@"\vref GEN.5:1",
					@"\v 1",
					@"\rem Note for chapter 5",
					@"\rcrd GEN 6", @"\c 6",
					@"\p",
					@"\vref GEN.6:1",
					@"\v 1",  @"\vt Six",
					@"\rem Note for chapter 6",
				};

				m_exporter.FileWriter.VerifyOutput(expected);
			}
		}
示例#27
0
		public void FindPictureInVerse_Found()
		{
			CheckDisposed();
			CreateExodusData();
			StTxtPara paraS1P0 = (StTxtPara)m_scr.ScriptureBooksOS[0].SectionsOS[1].ContentOA.ParagraphsOS[0];
			ITsString tss = paraS1P0.Contents.UnderlyingTsString;
			ITsStrFactory factory = TsStrFactoryClass.Create();
			using (DummyFileMaker fileMaker = new DummyFileMaker("junk.jpg", true))
			{
				CmPicture pict = new CmPicture(Cache, fileMaker.Filename,
					factory.MakeString("Test picture picture", Cache.DefaultVernWs),
					StringUtils.LocalPictures);
				int positionToInsertOrc = tss.Length;
				pict.InsertORCAt(tss, positionToInsertOrc, paraS1P0.Hvo,
					(int)StTxtPara.StTxtParaTags.kflidContents, 0);
				int iSection, iPara, ichOrcPos;
				Assert.IsTrue(m_editingHelper.FindPictureInVerse(new ScrReference(02001002, m_scr.Versification), pict.Hvo,
					out iSection, out iPara, out ichOrcPos));
				Assert.AreEqual(1, iSection);
				Assert.AreEqual(0, iPara);
				Assert.AreEqual(positionToInsertOrc, ichOrcPos);
			}
		}
示例#28
0
		public void ExportPara_Toolbox_Picture()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para;

				ReflectionHelper.SetField(m_exporter, "m_currentBookAbbrev", "GEN");

				para = ExportHelper.AppendParagraph(this, m_book, section,
					@"\c1\v1\iCmPicture|Picture of junk|" + filemaker.Filename
					+ @"|col|GEN 1--1|Copyright Pictures Unlimited 1922|My favorite caption||\^",
					m_wsVern, ScrStyleNames.NormalParagraph);

				ICmPicture picture = para.GetPictures()[0];
				picture.ScaleFactor = 48;
				string sInternalAbsPath = picture.PictureFileRA.AbsoluteInternalPath;
				try
				{
					// export
					m_exporter.MarkupSystem = MarkupType.Toolbox;
					m_exporter.ExportScriptureDomain = true;
					m_exporter.ExportBackTranslationDomain = false;
					m_exporter.ExportParagraph(para);

					string[] expected = new string[]
					{
						@"\rcrd GEN 1", @"\c 1", @"\p",
						@"\vref GEN.1:1",
						@"\v 1", @"\figdesc Picture of junk", @"\figcat " + sInternalAbsPath,
						@"\figlaypos col", @"\figrefrng GEN 1:1-GEN 1:31",
						@"\figcopy Copyright Pictures Unlimited 1922",
						@"\figcap My favorite caption",
						@"\figscale 48"
					};

					m_exporter.FileWriter.VerifyOutput(expected);
				}
				finally
				{
					if (sInternalAbsPath != null)
						FileUtils.Delete(sInternalAbsPath);
				}
			}
		}
示例#29
0
		public void HandleToolboxStylePictures_AllMarkersPresent_InterleavedBT()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				// initialize - process a \id segment to establish a book
				m_importer.TextSegment.FirstReference = new BCVRef(2, 0, 0);
				m_importer.TextSegment.LastReference = new BCVRef(2, 0, 0);
				m_importer.ProcessSegment("", @"\id");

				// ******** test a picture
				m_importer.TextSegment.FirstReference = new BCVRef(2, 1, 0);
				m_importer.TextSegment.LastReference = new BCVRef(2, 1, 0);
				m_importer.ProcessSegment("", @"\c");
				m_importer.ProcessSegment("", @"\p");
				m_importer.ProcessSegment("Caption for junk.jpg", @"\cap");
				m_importer.ProcessSegment(filemaker.Filename, @"\cat");
				m_importer.ProcessSegment("Copyright 1995, David C. Cook.", @"\figcopy");
				m_importer.ProcessSegment("Picture of baby Moses in a basket", @"\figdesc"); // English
				m_importer.ProcessSegment("span", @"\figlaypos");
				m_importer.ProcessSegment("EXO 1--1", @"\figrefrng");
				m_importer.ProcessSegment("56", @"\figscale");
				m_importer.ProcessSegment("BT Caption for junk.jpg", @"\btcap");
				m_importer.ProcessSegment("BT Copyright 1995, David C. Cook.", @"\btfigcopy");
				m_importer.ProcessSegment("Dibujo del bebe Moises en una canasta", @"\figdesc_es"); // Spanish
				m_importer.FinalizeImport();
				IScrBook exodus = m_importer.UndoInfo.ImportedVersion.BooksOS[0];
				IScrSection section = exodus.SectionsOS[0];
				IStTxtPara para = (IStTxtPara)section.ContentOA.ParagraphsOS[0];

				Assert.AreEqual("1" + StringUtils.kChObject.ToString(),
					para.Contents.Text);
				ITsString tss = para.Contents;
				Assert.AreEqual(2, tss.RunCount);
				string sObjData = tss.get_Properties(1).GetStrPropValue((int)FwTextPropType.ktptObjData);
				Guid guid = MiscUtils.GetGuidFromObjData(sObjData.Substring(1));
				ICmPicture picture = Cache.ServiceLocator.GetInstance<ICmPictureRepository>().GetObject(guid);
				try
				{
					Assert.AreEqual("Caption for junk.jpg", picture.Caption.VernacularDefaultWritingSystem.Text);
					Assert.AreEqual("BT Caption for junk.jpg", picture.Caption.AnalysisDefaultWritingSystem.Text);
					Assert.IsTrue(picture.PictureFileRA.InternalPath == picture.PictureFileRA.AbsoluteInternalPath);
					Assert.IsTrue(picture.PictureFileRA.InternalPath.IndexOf("junk") >= 0);
					Assert.IsTrue(picture.PictureFileRA.InternalPath.EndsWith(".jpg"));
					byte odt = Convert.ToByte(sObjData[0]);
					Assert.AreEqual((byte)FwObjDataTypes.kodtGuidMoveableObjDisp, odt);
					Assert.AreEqual("Picture of baby Moses in a basket", picture.Description.AnalysisDefaultWritingSystem.Text);
					Assert.AreEqual("Dibujo del bebe Moises en una canasta", picture.Description.get_String(
						Cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("es")).Text);
					Assert.AreEqual(PictureLayoutPosition.CenterOnPage, picture.LayoutPos);
					Assert.AreEqual(56, picture.ScaleFactor);
					Assert.AreEqual(PictureLocationRangeType.ReferenceRange, picture.LocationRangeType);
					Assert.AreEqual(02001001, picture.LocationMin);
					Assert.AreEqual(02001022, picture.LocationMax);
					Assert.AreEqual("Copyright 1995, David C. Cook.", picture.PictureFileRA.Copyright.VernacularDefaultWritingSystem.Text);
					Assert.AreEqual("BT Copyright 1995, David C. Cook.", picture.PictureFileRA.Copyright.AnalysisDefaultWritingSystem.Text);
				}
				finally
				{
					if (picture != null)
					{
						File.Delete(picture.PictureFileRA.AbsoluteInternalPath);
					}
				}
			}
		}
示例#30
0
		public void ExportPara_Paratext_Picture()
		{
			using (DummyFileMaker filemaker = new DummyFileMaker("junk.jpg", true))
			{
				IScrSection section = ExportHelper.CreateSection(this, m_book, "My section head");
				IStTxtPara para;

				ReflectionHelper.SetField(m_exporter, "m_currentBookAbbrev", "Jenn");

				para = ExportHelper.AppendParagraph(this, m_book, section,
					@"\c1\v1\iCmPicture|User-supplied picture|" + filemaker.Filename
					+ @"|col|GEN 1--1||My favorite caption||\^", m_wsVern, ScrStyleNames.NormalParagraph);

				ICmPicture picture = para.GetPictures()[0];
				ICmFile pictureFile = picture.PictureFileRA;
				string sInternalAbsPath = pictureFile.AbsoluteInternalPath;

				try
				{
					// export
					m_exporter.MarkupSystem = MarkupType.Paratext;
					m_exporter.ParatextProjectShortName = "ABC";
					m_exporter.ParatextProjectFolder = Path.GetTempPath(); // @"C:\TEMP"; // Bad idea, since C:\TEMP might not exist.
					m_exporter.ExportScriptureDomain = true;
					m_exporter.ExportBackTranslationDomain = false;
					m_exporter.ExportParagraph(para);

					string[] expected = new string[]
					{
						@"\c 1", @"\p",
						@"\v 1 \fig User-supplied picture|" + Path.GetFileName(pictureFile.InternalPath) +
						@"|col|GEN 1:1-GEN 1:31||My favorite caption|Jenn 1.1" +
// TODO (TE-7759)						"|ReferenceRange|100" +
						@"\fig*"
					};

					m_exporter.FileWriter.VerifyOutput(expected);
					Assert.AreEqual(1, m_exporter.PictureFilesToCopy.Count);
					Assert.AreEqual(sInternalAbsPath, m_exporter.PictureFilesToCopy[0]);
				}
				finally
				{
					if (pictureFile != null)
					{
						FileUtils.Delete(sInternalAbsPath);
					}
				}
			}
		}