本文整理汇总了C#中SIL.FieldWorks.FDO.Cellar.StTxtPara类的典型用法代码示例。如果您正苦于以下问题:C# StTxtPara类的具体用法?C# StTxtPara怎么用?C# StTxtPara使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StTxtPara类属于SIL.FieldWorks.FDO.Cellar命名空间,在下文中一共展示了StTxtPara类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: system
int m_wsUr; // Urdu writing system (used for Foreign style)
#endregion
#region Test setup
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// ------------------------------------------------------------------------------------
protected override void CreateTestData()
{
m_inMemoryCache.InitializeWritingSystemEncodings();
// create footnote
m_footnote = new StFootnote();
m_book = (ScrBook)m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis");
m_book.FootnotesOS.Append(m_footnote);
m_footnote.FootnoteMarker.Text = "o";
m_footnote.DisplayFootnoteMarker = true;
m_footnote.DisplayFootnoteReference = false;
// create one empty footnote para
StTxtPara para = new StTxtPara();
m_footnote.ParagraphsOS.Append(para);
para.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph);
m_strFact = TsStrFactoryClass.Create();
m_vernWs = Cache.LangProject.DefaultVernacularWritingSystem;
para.Contents.UnderlyingTsString = m_strFact.MakeString(string.Empty, m_vernWs);
m_footnotePara = (StTxtPara)m_footnote.ParagraphsOS[0];
m_wsUr = InMemoryFdoCache.s_wsHvos.Ur; // used with 'foreign' character style
m_wsDe = InMemoryFdoCache.s_wsHvos.De; // used for back translations
m_wsEs = InMemoryFdoCache.s_wsHvos.Es;
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:35,代码来源:StFootnoteTests.cs
示例2: VerifyParaDiff
/// <summary>overload for same end ref</summary>
public static void VerifyParaDiff(Difference diff,
BCVRef startAndEnd, DifferenceType type,
StTxtPara paraCurr, int ichMinCurr, int ichLimCurr,
StTxtPara paraRev, int ichMinRev, int ichLimRev)
{
VerifyParaDiff(diff, startAndEnd, startAndEnd, type,
paraCurr, ichMinCurr, ichLimCurr,
paraRev, ichMinRev, ichLimRev);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:10,代码来源:DiffTestHelper.cs
示例3: SetupTexts
public void SetupTexts()
{
// First make a regular text.
using (new UndoRedoTaskHelper(Cache, "ConstituentChartDatabaseTests - SetupTexts()", "ConstituentChartDatabaseTests - SetupTexts()"))
{
m_text1 = Cache.LangProject.TextsOC.Add(new Text());
m_text1.ContentsOA = new StText();
StTxtPara para0 = new StTxtPara();
m_text1.ContentsOA.ParagraphsOS.Append(para0);
//m_text1.ContentsOA.ParagraphsOS.Append(para1);
// 1 2 3 4 5 6
// 0123456789012345678901234567890123456789012345678901234567890123456789
// this is the first paragraph for our constituent chart database tests.
para0.Contents.UnderlyingTsString = m_tsf.MakeString("this is the first paragraph for our constituent chart database tests.",
Cache.DefaultVernWs);
}
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:17,代码来源:ConstituentChartDatabaseTests.cs
示例4: SetTitle
/// ------------------------------------------------------------------------------------
/// <summary>
/// Create a title paragrpaph for the given book.
/// </summary>
/// <param name="scrInMemoryCache">in-memory cache to use for testing</param>
/// <param name="book">The book</param>param>
/// <param name="sTitle">The text of the title. Can be a simple string or a format
/// string. (See InMemoryFdoCache.CreateFormatText for the definition of the
/// format string)</param>
/// ------------------------------------------------------------------------------------
internal static void SetTitle(ScrInMemoryFdoCache scrInMemoryCache, IScrBook book, string sTitle)
{
book.TitleOA = new StText();
if (sTitle[0] != '\\')
{
scrInMemoryCache.AddTitleToMockedBook(book.Hvo, sTitle);
}
else
{
// Create a more complex title from the given format string
// insert a new para in the title
StTxtPara para = new StTxtPara();
book.TitleOA.ParagraphsOS.Append(para);
// set the para's fields
scrInMemoryCache.AddFormatTextToMockedPara(book, para, sTitle, scrInMemoryCache.Cache.DefaultVernWs);
para.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.MainBookTitle);
}
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:29,代码来源:ExportHelper.cs
示例5: OnFormClosing
/// ------------------------------------------------------------------------------------
/// <summary>
///
/// </summary>
/// ------------------------------------------------------------------------------------
protected override void OnFormClosing(FormClosingEventArgs e)
{
base.OnFormClosing(e);
if (DialogResult == DialogResult.Cancel)
return;
FdoOwningSequence<IStPara> oldParas = m_error.ResolutionOA.ParagraphsOS;
ITsString[] newParas = m_text.Paragraphs;
// If there are fewer paragraphs in the new comment, then remove from the end
// of the old comment the number paragraphs that is the difference between
// the number of old and new paragraphs.
if (newParas.Length < oldParas.Count)
{
for (int i = oldParas.Count - 1; i >= newParas.Length; i--)
oldParas.RemoveAt(i);
}
for (int i = 0; i < newParas.Length; i++)
{
if (i < oldParas.Count)
{
// Reuse the old paragraph.
((StTxtPara)oldParas[i]).Contents.UnderlyingTsString = newParas[i];
}
else
{
// Create a new paragraph
StTxtPara newStPara = new StTxtPara();
oldParas.Append(newStPara);
newStPara.Contents.UnderlyingTsString = newParas[i];
ITsPropsFactory tspf = TsPropsFactoryClass.Create();
newStPara.StyleRules = tspf.MakeProps(ScrStyleNames.Remark, m_text.CurrentWs, 0);
}
}
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:42,代码来源:CheckingErrorCommentDlg.cs
示例6: VerifyParaAddedDiff
/// ------------------------------------------------------------------------------------
/// <summary>
/// A helper method for book merger tests-
/// Verifies the contents of the given difference
/// for types: missing/added paragraphs.
/// </summary>
/// <param name="diff">the given Difference</param>
/// <param name="start">The verse ref start.</param>
/// <param name="end">The verse ref end.</param>
/// <param name="type">Type of the diff.</param>
/// <param name="paraAdded">The paragraph added.</param>
/// <param name="paraDest">the destination paragraph</param>
/// <param name="ichDest">The character index in the destination paragraph,
/// where the added items could be inserted in the other book.</param>
/// ------------------------------------------------------------------------------------
public static void VerifyParaAddedDiff(Difference diff,
BCVRef start, BCVRef end, DifferenceType type,
StTxtPara paraAdded, StTxtPara paraDest, int ichDest)
{
Assert.AreEqual(start, diff.RefStart);
Assert.AreEqual(end, diff.RefEnd);
Assert.AreEqual(type, diff.DiffType);
switch (type)
{
case DifferenceType.ParagraphAddedToCurrent:
Assert.IsNull(diff.HvosSectionsRev);
Assert.AreEqual(paraAdded.Hvo, diff.HvoCurr);
Assert.AreEqual(0, diff.IchMinCurr);
Assert.AreEqual(paraAdded.Contents.Length, diff.IchLimCurr);
Assert.AreEqual(paraDest.Hvo, diff.HvoRev);
Assert.AreEqual(ichDest, diff.IchMinRev);
Assert.AreEqual(ichDest, diff.IchLimRev);
Assert.IsNull(diff.StyleNameCurr);
Assert.IsNull(diff.StyleNameRev);
break;
case DifferenceType.ParagraphMissingInCurrent:
Assert.IsNull(diff.HvosSectionsRev);
Assert.AreEqual(paraDest.Hvo, diff.HvoCurr);
Assert.AreEqual(ichDest, diff.IchMinCurr);
Assert.AreEqual(ichDest, diff.IchLimCurr);
Assert.AreEqual(paraAdded.Hvo, diff.HvoRev);
Assert.AreEqual(0, diff.IchMinRev);
Assert.AreEqual(paraAdded.Contents.Length, diff.IchLimRev);
Assert.IsNull(diff.StyleNameCurr);
Assert.IsNull(diff.StyleNameRev);
break;
}
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:55,代码来源:DiffTestHelper.cs
示例7: VerifyStanzaBreakAddedDiff
/// ------------------------------------------------------------------------------------
/// <summary>
/// A helper method for book merger tests-
/// Verifies the contents of the given difference
/// for types: missing/added empty paragraphs.
/// </summary>
/// <param name="diff">the given Difference</param>
/// <param name="startAndEnd">The starting and ending verse ref start.</param>
/// <param name="type">Type of the diff.</param>
/// <param name="paraAdded">The paragraph added.</param>
/// <param name="paraDest">the destination paragraph</param>
/// <param name="ichDest">The character index in the destination paragraph,
/// where the added items could be inserted in the other book.</param>
/// ------------------------------------------------------------------------------------
public static void VerifyStanzaBreakAddedDiff(Difference diff,
BCVRef startAndEnd, DifferenceType type,
StTxtPara paraAdded, /*string strAddedParaStyle,*/ StTxtPara paraDest, int ichDest)
{
Assert.IsTrue(diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent ||
diff.DiffType == DifferenceType.StanzaBreakMissingInCurrent);
//string addedParaStyle = (diff.DiffType == DifferenceType.StanzaBreakAddedToCurrent) ?
// diff.StyleNameCurr : diff.StyleNameRev;
//Assert.AreEqual(strAddedParaStyle, addedParaStyle);
VerifyParaAddedDiff(diff, startAndEnd, startAndEnd, type, paraAdded, paraDest, ichDest);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:26,代码来源:DiffTestHelper.cs
示例8: CreateParagraph
/// ------------------------------------------------------------------------------------
/// <summary>
/// Append a new <see cref="StTxtPara"/> to the given <see cref="StText"/>.
/// Set it with data accumulated in this builder.
/// </summary>
/// <param name="hvoOwner">HVO of the <see cref="StText"/> that is to own the new
/// paragraph</param>
/// <returns>A new StTextPara whose contents are built up from the prior calls
/// to <see cref="AppendRun"/> and whose style is set based on the current value of
/// <see cref="ParaStylePropsProxy"/>.</returns>
/// ------------------------------------------------------------------------------------
public StTxtPara CreateParagraph(int hvoOwner)
{
CheckDisposed();
// insert a new para in the owner's collection
StTxtPara para = new StTxtPara();
StText text = new StText(m_cache, hvoOwner);
text.ParagraphsOS.Append(para);
SetStTxtParaPropertiesAndClearBuilder(para, 0);
return para;
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:23,代码来源:StTxtParaBldr.cs
示例9: CreateFromStringRep_twoParas
public void CreateFromStringRep_twoParas()
{
CheckDisposed();
ITsStrBldr bldr = m_footnotePara.Contents.UnderlyingTsString.GetBldr();
bldr.Replace(0, 0, "Paragraph One", null);
m_footnotePara.Contents.UnderlyingTsString = bldr.GetString();
// create second para
StTxtPara para = new StTxtPara();
m_footnote.ParagraphsOS.Append(para);
para.StyleRules = StyleUtils.ParaStyleTextProps("Note Exegesis Paragraph");
bldr = TsStrBldrClass.Create();
bldr.Replace(0, 0, "Paragraph Two", StyleUtils.CharStyleTextProps("Foreign", m_wsUr));
para.Contents.UnderlyingTsString = bldr.GetString();
string footnoteRep = @"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
@"<RUN WS='fr'>Paragraph One</RUN></P><P><PS>Note Exegesis Paragraph</PS>" +
@"<RUN WS='ur' CS='Foreign'>Paragraph Two</RUN></P></FN>";
StFootnote footnote = StFootnote.CreateFromStringRep(m_book,
(int)ScrBook.ScrBookTags.kflidFootnotes, footnoteRep, 0, "Note Marker");
CompareFootnote(footnote);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:23,代码来源:StFootnoteTests.cs
示例10: VerifySubDiffTextCompared
/// ------------------------------------------------------------------------------------
/// <summary>
/// A helper method for book merger tests-
/// Verifies the contents of the given sub-difference
/// for a two-sided subDiff representing a text comparison. This overload does not
/// check for the starting and ending references for sub-diffs that are created without
/// that information.
/// </summary>
/// <param name="rootDiff">The root difference.</param>
/// <param name="iSubDiff">The sub difference to verify.</param>
/// <param name="subDiffType">Type of the sub difference.</param>
/// <param name="paraCurr">The current paragraph.</param>
/// <param name="ichMinCurr">The beginning character offset of the difference in the
/// current.</param>
/// <param name="ichLimCurr">The ending character offset of the difference in the
/// current.</param>
/// <param name="paraRev">The revision paragraph.</param>
/// <param name="ichMinRev">The beginning character offset of the difference in the
/// revision.</param>
/// <param name="ichLimRev">The ending character offset of the difference in the
/// current.</param>
/// <remarks>char styles are not verified here; test code should just check
/// those directly if relevant</remarks>
/// ------------------------------------------------------------------------------------
//TODO: use an iSubDiff parameter instead of the subDiff itself;
// use the following method as a model to verify the root diff type
// make a separate method for footnote subdiffs
public static void VerifySubDiffTextCompared(Difference rootDiff, int iSubDiff,
DifferenceType subDiffType,
StTxtPara paraCurr, int ichMinCurr, int ichLimCurr,
StTxtPara paraRev, int ichMinRev, int ichLimRev)
{
Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff];
// the Current para stuff
Assert.AreEqual((paraCurr != null) ? paraCurr.Hvo : 0, subDiff.HvoCurr);
Assert.AreEqual(ichMinCurr, subDiff.IchMinCurr);
Assert.AreEqual(ichLimCurr, subDiff.IchLimCurr);
// the Revision para stuff
Assert.AreEqual((paraRev != null) ? paraRev.Hvo : 0, subDiff.HvoRev);
Assert.AreEqual(ichMinRev, subDiff.IchMinRev);
Assert.AreEqual(ichLimRev, subDiff.IchLimRev);
// section stuff should be null
Assert.IsNull(subDiff.HvosSectionsRev);
Assert.IsNull(subDiff.HvosSectionsCurr);
// subDiffs may not have subDiffs, so far
Assert.IsNull(subDiff.SubDiffsForORCs);
Assert.IsNull(subDiff.SubDiffsForParas);
Assert.AreEqual(subDiffType, subDiff.DiffType);
if ((rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 ||
(rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0 ||
(rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0)
{
// check the subDiff for consistency with the root diff.
Assert.IsTrue((subDiff.DiffType & DifferenceType.TextDifference) != 0 ||
(subDiff.DiffType & DifferenceType.FootnoteAddedToCurrent) != 0 ||
(subDiff.DiffType & DifferenceType.FootnoteMissingInCurrent) != 0 ||
(subDiff.DiffType & DifferenceType.FootnoteDifference) != 0 ||
(subDiff.DiffType & DifferenceType.MultipleCharStyleDifferences) != 0 ||
(subDiff.DiffType & DifferenceType.CharStyleDifference) != 0 ||
(subDiff.DiffType & DifferenceType.PictureAddedToCurrent) != 0 ||
(subDiff.DiffType & DifferenceType.PictureMissingInCurrent) != 0 ||
(subDiff.DiffType & DifferenceType.PictureDifference) != 0 ||
subDiff.DiffType == DifferenceType.NoDifference, // (structure change only)
subDiff.DiffType.ToString() +
" is not a consistent subtype with split or merged paragraph differences.");
}
else
{
Assert.IsNotNull(paraCurr, "The current paragraph cannot be null except for para split/merge root diff");
Assert.IsNotNull(paraRev, "The revision paragraph cannot be null except for para split/merge root diff");
//check the root difference for consistency with this subDiff
if (subDiff.DiffType == DifferenceType.VerseMoved)
// ||
// subDiff.DiffType == DifferenceType.ParagraphMoved)
{
// this subDiff verse or paragraph was moved into an added section
Assert.IsTrue(rootDiff.DiffType == DifferenceType.SectionAddedToCurrent ||
rootDiff.DiffType == DifferenceType.SectionMissingInCurrent,
"inconsistent type of root difference");
}
else if (subDiff.DiffType == DifferenceType.TextDifference)
{
// this subDiff text difference is within a footnote
Assert.AreEqual(DifferenceType.FootnoteDifference, rootDiff.DiffType);
}
else
Assert.Fail("unexpected type of sub-diff");
}
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:95,代码来源:DiffTestHelper.cs
示例11: AppendRunToBt
/// ------------------------------------------------------------------------------------
/// <summary>
/// Append a run of text to a back translation of a paragraph.
/// </summary>
/// <param name="para">given paragraph</param>
/// <param name="ws">given writing system for the back translation</param>
/// <param name="runText">given text to append to back translation</param>
/// ------------------------------------------------------------------------------------
private void AppendRunToBt(StTxtPara para, int ws, string runText)
{
ICmTranslation trans = para.GetOrCreateBT();
ITsStrBldr bldr = trans.Translation.GetAlternative(ws).UnderlyingTsString.GetBldr();
ITsTextProps ttp = StyleUtils.CharStyleTextProps(null, ws);
int bldrLength = bldr.Length;
bldr.ReplaceRgch(bldrLength, bldrLength, runText, runText.Length, ttp);
trans.Translation.SetAlternative(bldr.GetString(), ws);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:17,代码来源:FdoScriptureTests.cs
示例12: NotifyParagraph
/// ------------------------------------------------------------------------------------
/// <summary>
/// Notifies a paragraph that needs to have its highlighting refreshed.
/// </summary>
/// <param name="hvoPara"></param>
/// ------------------------------------------------------------------------------------
private void NotifyParagraph(int hvoPara)
{
if (m_cache.IsRealObject(hvoPara, StTxtPara.kClassId))
{
StTxtPara para = new StTxtPara(m_cache, hvoPara);
m_cache.PropChanged(null, PropChangeType.kpctNotifyAll, hvoPara,
(int)StTxtPara.StParaTags.kflidStyleRules, 0, 1, 1);
}
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:15,代码来源:DiffDialog.cs
示例13: ArchiveDraft_TestFootnoteOrder
public void ArchiveDraft_TestFootnoteOrder()
{
CheckDisposed();
int draftCount = m_scr.ArchivedDraftsOC.Count;
ScrBook james = (ScrBook)m_scr.ScriptureBooksOS[1];
int hvoBookRef = m_fdoCache.ScriptureReferenceSystem.BooksOS[58].Hvo;
// Add a footnote to the first content para2 of the second section.
FdoOwningSequence<IStPara> contentParas = james.SectionsOS[1].ContentOA.ParagraphsOS;
StTxtPara para2 = (StTxtPara)contentParas[0];
StFootnote footnoteOrig3 = InsertTestFootnote(james, para2, 0, 0);
StTxtPara para1 = new StTxtPara();
contentParas.InsertAt(para1, 0);
StFootnote footnoteOrig2 = InsertTestFootnote(james, para1, 0, 0);
StText titleText = new StText();
StTxtPara title = new StTxtPara();
james.TitleOA = titleText;
titleText.ParagraphsOS.Append(title);
StFootnote footnoteOrig1 = InsertTestFootnote(james, title, 0, 0);
// archive draft
IScrDraft draft = m_scr.CreateSavedVersion("FootnoteOrder james", new int[] { james.Hvo });
Assert.AreEqual(draftCount + 1, m_scr.ArchivedDraftsOC.Count);
Assert.AreEqual("FootnoteOrder james", draft.Description);
Assert.AreEqual(1, draft.BooksOS.Count);
IScrBook revision = draft.BooksOS.FirstItem;
Assert.IsFalse(james.Hvo == revision.Hvo);
Assert.AreEqual(james.SectionsOS.Count, revision.SectionsOS.Count);
IScrSection revSection1 = revision.SectionsOS[0];
IScrSection revSection2 = revision.SectionsOS[1];
Assert.IsTrue(james.SectionsOS[0].Hvo != revSection1.Hvo);
Assert.IsTrue(james.SectionsOS[0].Hvo != revSection2.Hvo);
Assert.IsTrue(james.SectionsOS[1].Hvo != revSection1.Hvo);
Assert.IsTrue(james.SectionsOS[1].Hvo != revSection2.Hvo);
FdoOwningSequence<IStPara> s2Paras = revSection2.ContentOA.ParagraphsOS;
Assert.AreEqual(james.SectionsOS[1].ContentOA.ParagraphsOS.Count,
s2Paras.Count);
StTxtPara titleRev = (StTxtPara)revision.TitleOA.ParagraphsOS[0];
StTxtPara paraRev1 = (StTxtPara)s2Paras[0];
StTxtPara paraRev2 = (StTxtPara)s2Paras[1];
Assert.IsFalse(title.Hvo == titleRev.Hvo);
Assert.IsFalse(para1.Hvo == paraRev1.Hvo);
Assert.IsFalse(para2.Hvo == paraRev2.Hvo);
Assert.AreEqual(hvoBookRef, revision.BookIdRAHvo);
// Check the footnote
Assert.AreEqual(james.FootnotesOS.Count, revision.FootnotesOS.Count);
Assert.AreEqual(footnoteOrig1.Hvo, james.FootnotesOS[0].Hvo);
Assert.AreEqual(footnoteOrig2.Hvo, james.FootnotesOS[1].Hvo);
Assert.AreEqual(footnoteOrig3.Hvo, james.FootnotesOS[2].Hvo);
IStFootnote footnoteRev1 = revision.FootnotesOS[0];
IStFootnote footnoteRev2 = revision.FootnotesOS[1];
IStFootnote footnoteRev3 = revision.FootnotesOS[2];
Assert.IsTrue(footnoteRev1.Hvo != footnoteOrig1.Hvo);
Assert.IsTrue(footnoteRev2.Hvo != footnoteOrig2.Hvo);
Assert.IsTrue(footnoteRev3.Hvo != footnoteOrig3.Hvo);
VerifyFootnote(footnoteRev1, titleRev, 0);
VerifyFootnote(footnoteRev2, paraRev1, 0);
VerifyFootnote(footnoteRev3, paraRev2, 0);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:64,代码来源:FdoScriptureTests.cs
示例14: GetTextTokens_EmptyTsStringWithMissingWs
public void GetTextTokens_EmptyTsStringWithMissingWs()
{
ScrChecksDataSource dataSource = new ScrChecksDataSource(Cache);
int iExodus = 2;
IScrBook exodus = m_scrInMemoryCache.AddBookToMockedScripture(iExodus, "Exodus");
m_scrInMemoryCache.AddTitleToMockedBook(exodus.Hvo, "Exodus");
IScrSection section = m_scrInMemoryCache.AddIntroSectionToMockedBook(exodus.Hvo);
// Make the heading paragraph empty, and with no writing system set
CacheBase cachebase = m_inMemoryCache.CacheAccessor;
StTxtPara paraIntroSectHead = new StTxtPara(Cache, cachebase.NewHvo(StTxtPara.kClassId));
cachebase.AppendToFdoVector(section.HeadingOAHvo,
(int)StText.StTextTags.kflidParagraphs, paraIntroSectHead.Hvo);
cachebase.SetBasicProps(paraIntroSectHead.Hvo, section.HeadingOAHvo, (int)StTxtPara.kClassId,
(int)StText.StTextTags.kflidParagraphs, 1);
ITsPropsFactory propFact = TsPropsFactoryClass.Create();
paraIntroSectHead.StyleRules = propFact.MakeProps(ScrStyleNames.IntroSectionHead, 0, 0);
ITsStrBldr strBldr = TsStrBldrClass.Create();
strBldr.Replace(0, 0, "", null);
paraIntroSectHead.Contents.UnderlyingTsString = strBldr.GetString();
cachebase.SetGuid(paraIntroSectHead.Hvo, (int)CmObjectFields.kflidCmObject_Guid, Guid.NewGuid());
// Set up the intro section contents
StTxtPara paraIntroSectContent = m_scrInMemoryCache.AddParaToMockedText(section.ContentOAHvo,
ScrStyleNames.IntroParagraph);
m_scrInMemoryCache.AddRunToMockedPara(paraIntroSectContent, "There's not much to say, really.", null);
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]);
BCVRef expectedRef = new BCVRef(iExodus, 1, 0);
VerifyToken(tokens, string.Empty, ScrStyleNames.IntroSectionHead, string.Empty, expectedRef, expectedRef,
true, TextType.Other, null, paraIntroSectHead, (int)StTxtPara.StTxtParaTags.kflidContents);
VerifyToken(tokens, "There's not much to say, really.", ScrStyleNames.IntroParagraph, string.Empty, paraIntroSectContent);
Assert.IsFalse(tokens.MoveNext());
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:37,代码来源:FdoScriptureTests.cs
示例15: SetStTxtParaPropertiesAndClearBuilder
/// ------------------------------------------------------------------------------------
/// <summary>
/// Sets the StyleRules and Contents properties for the new <see cref="StTxtPara"/>;
/// then clears the builder.
/// </summary>
/// <param name="para">The <see cref="StTxtPara"/> that was just created</param>
/// <param name="iPos">index of new paragraph</param>
/// ------------------------------------------------------------------------------------
private void SetStTxtParaPropertiesAndClearBuilder(StTxtPara para, int iPos)
{
// sets the new StTxtPara properties, with contents built up from prior calls
ITsTextProps props = (ParaStylePropsProxy == null ?
ParaProps : ParaStylePropsProxy.Props);
para.StyleRules = props;
para.Contents.UnderlyingTsString = m_ParaStrBldr.GetString();
m_cache.PropChanged(null, PropChangeType.kpctNotifyAll,
para.OwnerHVO,
(int)StText.StTextTags.kflidParagraphs, iPos, 1, 0);
// Clear the builder, for new paragraph
m_ParaStrBldr.Replace(0, Length, null, null);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:24,代码来源:StTxtParaBldr.cs
示例16: Export
public void Export()
{
using (MemoryStream stream = new MemoryStream())
{
//Set up some cells.
int[] allParaWfics = m_helper.MakeAnnotationsUsedN(5);
// This block makes the first row, puts CCAs in cells 1 and 2, and list refs in cells 1 and 2
CmIndirectAnnotation row0 = m_helper.MakeFirstRow();
int[] movedItems = new int[] { allParaWfics[1] };
CmIndirectAnnotation cca0_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[0] }, row0);
ICmPossibility marker = m_helper.GetAMarker();
ICmBaseAnnotation cca0_1b = m_helper.MakeMarkerAnnotation(1, row0, marker);
CmIndirectAnnotation cca0_2 = m_helper.MakeColumnAnnotation(2, movedItems, row0);
ICmPossibility marker2 = m_helper.GetAnotherMarker();
ICmBaseAnnotation cca0_2b = m_helper.MakeMarkerAnnotation(2, row0, marker2);
ICmBaseAnnotation cca0_2c = m_helper.MakeMarkerAnnotation(2, row0, marker);
// Now another row, and cell 4 on the first has a ref to it. The new row has a CCA with two wfics in cell 1. The cell is
// two columns wide, being merged with the previous cell.
CmIndirectAnnotation row1 = m_helper.MakeSecondRow();
ICmIndirectAnnotation cca0_4 = m_helper.MakeDependentClauseMarker(row0, 4, new int[] { row1.Hvo }, "song", "2");
CmIndirectAnnotation cca1_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[2], allParaWfics[3] }, row1);
ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, cca1_1.Hvo, ConstituentChartLogic.mergeBeforeTag, true);
// Let's have some notes on row 0.
StText notesText = new StText();
row0.TextOA = notesText;
StTxtPara notesPara = new StTxtPara();
notesText.ParagraphsOS.Append(notesPara);
notesPara.Contents.UnderlyingTsString = Cache.MakeAnalysisTss("This is a test note");
// And some moved text in row 1
CmIndirectAnnotation cca1_2 = m_helper.MakeColumnAnnotation(2, new int[] { allParaWfics[4] }, row1);
ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, cca1_2.Hvo,
ConstituentChartLogic.MovedTextFeatureName, true);
CmIndirectAnnotation cca2_3 = m_helper.MakeMovedTextAnnotation(3, cca1_2, row1, "Preposed");
// We need four rows to properly test the variations on endPara/endSent
CmIndirectAnnotation row2 = m_helper.MakeRow(m_chart, "2");
ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row2.Hvo, ConstituentChartLogic.EndSentFeatureName, true);
CmIndirectAnnotation row3 = m_helper.MakeRow(m_chart, "3");
ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row3.Hvo, ConstituentChartLogic.EndParaFeatureName, true);
ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row3.Hvo, ConstituentChartLogic.EndSentFeatureName, true);
CmIndirectAnnotation row4 = m_helper.MakeRow(m_chart, "4");
XmlWriter writer = new XmlTextWriter(stream, Encoding.UTF8);
ConstChartVc vc = new ConstChartVc(m_chartBody);
vc.LineChoices = m_chartBody.LineChoices;
DiscourseExporter exporter = new DiscourseExporter(m_inMemoryCache.Cache, writer, m_chart.Hvo,
vc, m_inMemoryCache.Cache.DefaultAnalWs);
writer.WriteStartDocument();
writer.WriteStartElement("document");
exporter.ExportDisplay();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush(); // Close makes it unuseable
stream.Position = 0;
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
string result = reader.ReadToEnd();
XmlDocument doc = new XmlDocument();
doc.LoadXml(result);
XmlNode docNode = doc.DocumentElement;
Assert.AreEqual("document", docNode.Name);
XmlNode chartNode = VerifyNode("chart", docNode, 0, "chart", 7, 0);
VerifyTitleRow(chartNode);
VerifyTitle2Row(chartNode);
VerifyFirstDataRow(chartNode);
VerifySecondDataRow(chartNode);
XmlNode thirdRow = VerifyNode("row", chartNode, 4, "row", 8, 3);
AssertAttr(thirdRow, "endSent", "true");
XmlNode fourthRow = VerifyNode("row", chartNode, 5, "row", 8, 3);
AssertAttr(fourthRow, "endPara", "true");
XmlNode langNode = VerifyNode("languages", docNode, 1, "languages", 2, 0);
XmlNode enNode = VerifyNode("english lang node", langNode, 0, "language", 0, 2);
AssertAttr(enNode, "lang", "en");
AssertAttr(enNode, "font", null); // don't verify exact font, may depend on installation.
}
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:84,代码来源:DiscourseExportTests.cs
示例17: VerifySubDiffParaReferencePoints
/// ------------------------------------------------------------------------------------
/// <summary>
/// A helper method for book merger tests-
/// Verifies the contents of the given difference and given SubDiffForParas
/// when the subdiff provides only reference points (i.e. IPs) as the first subdiff.
/// for rootdiff types: ParagraphStructureChange, ParagraphSplitInCurrent,
/// ParagraphMergedInCurrent.
/// </summary>
/// <param name="rootDiff">The root diff.</param>
/// <param name="iSubDiff">The i sub diff.</param>
/// <param name="paraCurr">The para curr.</param>
/// <param name="ichCurr">The ich curr.</param>
/// <param name="paraRev">The para rev.</param>
/// <param name="ichRev">The ich rev.</param>
/// ------------------------------------------------------------------------------------
public static void VerifySubDiffParaReferencePoints(Difference rootDiff, int iSubDiff,
StTxtPara paraCurr, int ichCurr,
StTxtPara paraRev, int ichRev)
{
Assert.IsTrue((rootDiff.DiffType & DifferenceType.ParagraphStructureChange) != 0 ||
(rootDiff.DiffType & DifferenceType.ParagraphSplitInCurrent) != 0 ||
(rootDiff.DiffType & DifferenceType.ParagraphMergedInCurrent) != 0);
// a para reference point subDiff must be at index 0 (preceeding the ParaAdded/Missing subdiffs)
Assert.AreEqual(0, iSubDiff);
Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff];
Assert.AreEqual(DifferenceType.NoDifference, subDiff.DiffType);
Assert.AreEqual(paraCurr.Hvo, subDiff.HvoCurr);
Assert.AreEqual(ichCurr, subDiff.IchMinCurr);
Assert.AreEqual(ichCurr, subDiff.IchLimCurr);
Assert.AreEqual(paraRev.Hvo, subDiff.HvoRev);
Assert.AreEqual(ichRev, subDiff.IchMinRev);
Assert.AreEqual(ichRev, subDiff.IchLimRev);
Assert.IsNull(subDiff.HvosSectionsRev);
Assert.IsNull(subDiff.HvosSectionsRev);
Assert.IsNull(subDiff.StyleNameCurr);
Assert.IsNull(subDiff.StyleNameRev);
Assert.IsNull(subDiff.SubDiffsForORCs);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:42,代码来源:DiffTestHelper.cs
示例18: GetTextRepresentation_twoParas
public void GetTextRepresentation_twoParas()
{
CheckDisposed();
m_footnotePara.Contents.UnderlyingTsString =
m_strFact.MakeString("Paragraph One", m_vernWs);
// create second para
StTxtPara para = new StTxtPara();
m_footnote.ParagraphsOS.Append(para);
// Set the paragraph style
para.StyleRules = StyleUtils.ParaStyleTextProps("Note Exegesis Paragraph");
ITsStrBldr bldr = TsStrBldrClass.Create();
bldr.Replace(0, 0, "Paragraph Two", StyleUtils.CharStyleTextProps(
"Foreign", m_wsUr));
para.Contents.UnderlyingTsString = bldr.GetString();
string result = m_footnote.GetTextRepresentation();
Assert.AreEqual(@"<FN><M>o</M><ShowMarker/><P><PS>Note General Paragraph</PS>" +
@"<RUN WS='fr'>Paragraph One</RUN></P><P><PS>Note Exegesis Paragraph</PS>" +
@"<RUN WS='ur' CS='Foreign'>Paragraph Two</RUN></P></FN>", result);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:24,代码来源:StFootnoteTests.cs
示例19: VerifySubDiffParaAdded
/// ------------------------------------------------------------------------------------
/// <summary>
/// A helper method for book merger tests-
/// Verifies the contents of the given difference and given SubDiffForParas
/// for subdiff types: missing/added paragraphs.
/// </summary>
/// <param name="rootDiff">The root diff.</param>
/// <param name="iSubDiff">The para subdiff index.</param>
/// <param name="subDiffType">diffType of the subdiff.</param>
/// <param name="paraAdded">The para added.</param>
/// <param name="ichLim">The ichlim for the paraAdded. Often this may be the end of the para,
/// or it may indicate only the first portion (ScrVerse) of the final paragraph.</param>
/// ------------------------------------------------------------------------------------
public static void VerifySubDiffParaAdded(Difference rootDiff, int iSubDiff,
DifferenceType subDiffType, StTxtPara paraAdded, int ichLim)
{
Assert.AreEqual(DifferenceType.ParagraphStructureChange, rootDiff.DiffType);
// a ParaAdded/Missing subDiff must not be at index 0 (paragraph reference points must be in that subdiff
Assert.LessOrEqual(1, iSubDiff);
Difference subDiff = rootDiff.SubDiffsForParas[iSubDiff];
Assert.AreEqual(subDiffType, subDiff.DiffType);
switch (subDiffType)
{
case DifferenceType.ParagraphAddedToCurrent:
Assert.AreEqual(paraAdded.Hvo, subDiff.HvoCurr);
Assert.AreEqual(0, subDiff.IchMinCurr);
Assert.AreEqual(ichLim, subDiff.IchLimCurr); //subDiff may be only first portion of the final paragraph
Assert.AreEqual(0, subDiff.HvoRev);
Assert.AreEqual(0, subDiff.IchMinRev);
Assert.AreEqual(0, subDiff.IchLimRev);
break;
case DifferenceType.ParagraphMissingInCurrent:
Assert.AreEqual(0, subDiff.HvoCurr);
Assert.AreEqual(0, subDiff.IchMinCurr);
Assert.AreEqual(0, subDiff.IchLimCurr);
Assert.AreEqual(paraAdded.Hvo, subDiff.HvoRev);
Assert.AreEqual(0, subDiff.IchMinRev);
Assert.AreEqual(ichLim, subDiff.IchLimRev); //subDiff may be only first portion of the final paragraph
break;
default:
Assert.Fail("Invalid subDiff type for a Paragraph Added/Missing subDiff");
break;
}
Assert.IsNull(subDiff.HvosSectionsRev);
Assert.IsNull(subDiff.HvosSectionsRev);
Assert.IsNull(subDiff.StyleNameCurr);
Assert.IsNull(subDiff.StyleNameRev);
Assert.IsNull(subDiff.SubDiffsForORCs);
}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:56,代码来源:DiffTestHelper.cs
示例20: AddOverridesToHighlightFootnoteDiff
/// ------------------------------------------------------------------------------------
/// <summary>
/// Adds the overrides to highlight a footnote diff.
/// </summary>
/// <param name="hvo">The hvo of the footnote paragraph.</param>
/// ------------------------------------------------------------------------------------
private void AddOverridesToHighlightFootnoteDiff(int hvo)
{
Difference diff = FindSubDiffForFootnote(hvo);
if (diff == null)
return;
StTxtPara para = new StTxtPara(Cache, hvo);
// Get the footnote which contains the paragraph.
int ownerHvo = para.OwnerHVO;
Debug.Assert(m_cache.GetClassOfObject(ownerHvo) == StFootnote.kClassId);
if (m_cache.GetClassOfObject(ownerHvo) != StFootnote.kClassId)
return; //don't override the props for this para; continue on gracefully
ScrFootnote footnote = new ScrFootnote(Cache, ownerHvo);
// Only add offset to first paragraph in footnote (should only be one para)
int offset = 0;
if (footnote.ParagraphsOS[0].Hvo == hvo)
{
int refLength = footnote.GetReference(m_wsDefault).Length;
int markerLength = footnote.FootnoteMarker.Length;
//add one for the space in between (added in StVc)
offset = refLength + markerLength + 1;
}
const uint knNinch =
|
请发表评论