public void MakeTagAnnotation_CompleteWith3Wfics() { // Provide hvoTagPoss and SelectedWfics, create a markup tag and examine it. // Setup the SelectedWfics property List <int> tempList = new List <int> (); tempList.Add(m_hvoWfics[0]); tempList.Add(m_hvoWfics[1]); tempList.Add(m_hvoWfics[2]); m_tagChild.SelectedWfics = tempList; // SUT ICmIndirectAnnotation tagAnn = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[0]); // Verification Assert.IsNotNull(tagAnn, "Should have made a Tag."); Assert.AreEqual(s_kTextTagAnnType, tagAnn.AnnotationTypeRAHvo, "TextTag has wrong AnnotationType."); Assert.AreEqual(m_possTagHvos[0], tagAnn.InstanceOfRAHvo, "Text Tag has wrong possibility Hvo."); Assert.AreEqual(3, tagAnn.AppliesToRS.Count); for (int i = 0; i < 3; i++) { Assert.AreEqual(tempList[i], tagAnn.AppliesToRS[i].Hvo, "Something wrong in TextTag AppliesTo[" + i + "]."); } }
public void MakeTagAnnot_ExistTag_CompleteOverlap() { // This test will need changing when we allow multiple lines of tagging. // Setup the SelectedWfics property for first tag List <int> tempList = new List <int> (); tempList.Add(m_hvoWfics[1]); tempList.Add(m_hvoWfics[2]); m_tagChild.SelectedWfics = tempList; int hvoInitialTag = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[0]).Hvo; // Make sure SelectedWfics property is still set to the same Wfics m_tagChild.SelectedWfics = tempList; // SUT // Make a second tag annotation with a different possibility pointing to the same Wfics ICmIndirectAnnotation sUTTag = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[1]); // Verification Assert.IsNotNull(sUTTag, "Should have made a Tag."); // The first tag should no longer exist in the Cache AssertTagDeleted(hvoInitialTag, "Should have deleted the initial tag."); }
internal void VerifyDeleteCcasEvent(ICmIndirectAnnotation row, int ihvo, int chvo) { object[] event1 = VerifyEventExists("delete ccas", 3); Assert.AreEqual(row.Hvo, (event1[1] as ICmIndirectAnnotation).Hvo); Assert.AreEqual(ihvo, (int)event1[2]); Assert.AreEqual(chvo, (int)event1[3]); }
/// <summary> /// Figure out what columns should be available, given a selected row. /// </summary> /// <returns></returns> internal int[] GetColumnChoices(ICmIndirectAnnotation row) { if (row.Hvo != SentElem.GetOriginRow.Hvo) { CollectAllColumnsToCombo(); return(SentElem.AllChartCols); } int ccols = SentElem.AllChartCols.Length; int icurCol = SentElem.GetOriginColumnIndex; if (Prepose) { // Collect columns following clicked one ccols = ccols - icurCol - 1; icurCol++; } else { // Collect columns preceding clicked one ccols = icurCol; icurCol = 0; } int[] result = new int[Math.Max(0, ccols)]; for (int i = 0; i < ccols; i++) { result[i] = SentElem.AllChartCols[i + icurCol]; } return(result); }
internal ICmBaseAnnotation MakeMarkerAnnotation(int icol, ICmIndirectAnnotation row, ICmPossibility marker) { CmBaseAnnotation cba = MakeBaseAnnotation(); cba.BeginObjectRA = marker; InitializeCca(cba, icol, row); return(cba); }
internal void CallMergeCellContents(int icolSrc, ICmIndirectAnnotation rowSrc, int icolDst, ICmIndirectAnnotation rowDst, bool forward) { ChartLocation srcCell = new ChartLocation(icolSrc, rowSrc); ChartLocation dstCell = new ChartLocation(icolDst, rowDst); MergeCellContents(srcCell, dstCell, forward); }
internal void VerifyChangeParentEvent(int[] wficsToMove, ICmIndirectAnnotation ccaSrc, ICmIndirectAnnotation ccaDst, int srcIndex, int dstIndex) { object[] event1 = VerifyEventExists("change parent", 5); Assert.AreEqual(wficsToMove, event1[1] as int[]); Assert.AreEqual(ccaSrc.Hvo, (event1[2] as ICmIndirectAnnotation).Hvo); Assert.AreEqual(ccaDst.Hvo, (event1[3] as ICmIndirectAnnotation).Hvo); Assert.AreEqual(srcIndex, (int)event1[4]); Assert.AreEqual(dstIndex, (int)event1[5]); }
internal void VerifyChangeRowEvent(int[] ccasToMove, ICmIndirectAnnotation RowSrc, ICmIndirectAnnotation rowDst, int srcIndex, int dstIndex) { object[] event1 = VerifyEventExists("change row", 5); Assert.AreEqual(ccasToMove, event1[1] as int[]); Assert.AreEqual(RowSrc.Hvo, (event1[2] as ICmIndirectAnnotation).Hvo); Assert.AreEqual(rowDst.Hvo, (event1[3] as ICmIndirectAnnotation).Hvo); Assert.AreEqual(srcIndex, (int)event1[4]); Assert.AreEqual(dstIndex, (int)event1[5]); }
// Make a column annotation for the specified column that groups the specified words // and append to the specified row. internal CmIndirectAnnotation MakeColumnAnnotation(int icol, int[] words, ICmIndirectAnnotation row) { CmIndirectAnnotation cca = MakeIndirectAnnotation(); for (int i = 0; i < words.Length; i++) { cca.AppliesToRS.Append(words[i]); } InitializeCca(cca, icol, row); return(cca); }
public override void DeleteCcas(ICmIndirectAnnotation row, int ihvo, int chvo) { if (m_fRecordBasicEdits) { m_events.Add(new object[] { "delete ccas", row, ihvo, chvo }); } else { base.DeleteCcas(row, ihvo, chvo); } }
public void MakeTagAnnotation_WithNoWfic() { // Provide hvoTagPoss and SelectedWfics, create a markup tag and examine it. // Setup the SelectedWfics property m_tagChild.SelectedWfics = null; // SUT ICmIndirectAnnotation tagAnn = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[m_cposs - 1]); Assert.IsNull(tagAnn, "MakeTextTagAnn must return null if no Wfics are selected."); }
public override void ChangeColumn(ICmAnnotation[] ccasToMove, int hvoNewCol, ICmIndirectAnnotation row) { if (m_fRecordBasicEdits) { m_events.Add(new object[] { "change column", ccasToMove, hvoNewCol, row }); } else { base.ChangeColumn(ccasToMove, hvoNewCol, row); } }
public override void ChangeRow(int[] ccasToMove, ICmIndirectAnnotation rowSrc, ICmIndirectAnnotation rowDst, int srcIndex, int dstIndex) { if (m_fRecordBasicEdits) { m_events.Add(new object[] { "change row", ccasToMove, rowSrc, rowDst, srcIndex, dstIndex }); } else { base.ChangeRow(ccasToMove, rowSrc, rowDst, srcIndex, dstIndex); } }
public override void ChangeCca(int[] wficsToMove, ICmIndirectAnnotation ccaSrc, ICmIndirectAnnotation ccaDst, int srcIndex, int dstIndex) { if (m_fRecordBasicEdits) { m_events.Add(new object[] { "change parent", wficsToMove, ccaSrc, ccaDst, srcIndex, dstIndex }); } else { base.ChangeCca(wficsToMove, ccaSrc, ccaDst, srcIndex, dstIndex); } }
public void FindCcaInNextColWithThreeInCol0() { int[] allParaWfics = m_helper.MakeAnnotationsUsedN(4); CmIndirectAnnotation row0 = m_helper.MakeFirstRow(); ICmIndirectAnnotation cca0_0 = m_helper.MakeColumnAnnotation(0, new int[] { allParaWfics[0] }, row0); ICmIndirectAnnotation cca0_0b = m_helper.MakeColumnAnnotation(0, new int[] { allParaWfics[1] }, row0); ICmIndirectAnnotation cca0_0c = m_helper.MakeColumnAnnotation(0, new int[] { allParaWfics[2] }, row0); ICmIndirectAnnotation cca0_3 = m_helper.MakeColumnAnnotation(3, new int[] { allParaWfics[4] }, row0); ChartLocation cell = MakeLocObj(row0, 2); int ihvoResult = m_logic.CallFindIndexOfCcaInLaterColumn(cell); Assert.AreEqual(3, ihvoResult); }
// Make a segment and its free translation. Append to or set up the segments property // of the para and set up the FT property of the segment. ICmIndirectAnnotation MakeFt(IStTxtPara para, string text, int beginOffset, int length) { ICmBaseAnnotation seg = MakeSegment(para, beginOffset, length); ICmIndirectAnnotation ft = CmIndirectAnnotation.CreateUnownedIndirectAnnotation(Cache); ft.AppliesToRS.Append(seg); ft.Comment.SetAlternative(text, m_wsTrans); ft.AnnotationTypeRAHvo = m_hvoFtDefn; // Backref links para.Cache.VwCacheDaAccessor.CacheObjProp(seg.Hvo, kflidFT, ft.Hvo); return(ft); }
/// <summary> /// Verify that there is a row with the specified index that has a cell with the specified /// index which belongs to the specified column (instanceOf) and appliesTo the specified words /// and has the specified marker (if any). /// </summary> /// <param name="rowIndex"></param> /// <param name="cellIndex"></param> /// <param name="hvoColumn"></param> /// <param name="words"></param> /// <param name="marker"></param> internal void VerifyCca(int rowIndex, int ccaIndex, int hvoColumn, int[] words, string marker) { ICmIndirectAnnotation cca = VerifyCcaBasic(rowIndex, ccaIndex, hvoColumn) as ICmIndirectAnnotation; Assert.IsNotNull(cca, "Cca should be indirect annotation"); Assert.AreEqual(words, cca.AppliesToRS.HvoArray); string comment = cca.Comment.AnalysisDefaultWritingSystem.Text; if (comment == null) { comment = ""; } Assert.AreEqual(marker, comment); Assert.AreEqual(CmAnnotationDefn.ConstituentChartAnnotation(Cache), cca.AnnotationTypeRA); }
public void MakeTagAnnot_MultipleExistTags_Overlap() { // This test will need changing when we allow multiple lines of tagging. // Setup the SelectedWfics property for first (existing) tag List <int> tempList = new List <int> (); tempList.Add(m_hvoWfics[1]); tempList.Add(m_hvoWfics[2]); m_tagChild.SelectedWfics = tempList; int hvoOldTag1 = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[0]).Hvo; // Setup the SelectedWfics property for second (existing) tag List <int> tempList1 = new List <int> (); tempList1.Add(m_hvoWfics[3]); tempList1.Add(m_hvoWfics[4]); m_tagChild.SelectedWfics = tempList1; int hvoOldTag2 = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[1]).Hvo; // Setup the SelectedWfics property for SUT tag // These overlap with both existing tags List <int> tempList2 = new List <int> (); tempList2.Add(m_hvoWfics[2]); tempList2.Add(m_hvoWfics[3]); m_tagChild.SelectedWfics = tempList2; // SUT // Make a third tag annotation with a different possibility pointing to the new Wfics ICmIndirectAnnotation tagSUT = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[2]); // Verification // Verify new tag Assert.IsNotNull(tagSUT, "Should have made a Tag."); Assert.AreEqual(m_possTagHvos[2], tagSUT.InstanceOfRAHvo, "Text Tag has wrong possibility Hvo."); Assert.AreEqual(2, tagSUT.AppliesToRS.Count); Assert.AreEqual(m_hvoWfics[2], tagSUT.AppliesToRS[0].Hvo, "Something wrong in new TextTag AppliesTo[0]."); Assert.AreEqual(m_hvoWfics[3], tagSUT.AppliesToRS[1].Hvo, "Something wrong in new TextTag AppliesTo[1]."); // The old tags (2) should no longer exist in the Cache AssertTagDeleted(hvoOldTag1, "Should have deleted the first pre-existing tag."); AssertTagDeleted(hvoOldTag2, "Should have deleted the second pre-existing tag."); }
public void MakeTagAnnotation_With1Wfic() { // Provide hvoTagPoss and SelectedWfics, create a markup tag and examine it. // Setup the SelectedWfics property List <int> tempList = new List <int> (); tempList.Add(m_hvoWfics[1]); m_tagChild.SelectedWfics = tempList; // SUT // Use the last possibility tag in the first list of tags ICmIndirectAnnotation tagAnn = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[m_cposs - 1]); // Verification Assert.IsNotNull(tagAnn, "Should have made a Tag."); Assert.AreEqual(m_possTagHvos[m_cposs - 1], tagAnn.InstanceOfRAHvo, "Text Tag has wrong possibility Hvo."); Assert.AreEqual(1, tagAnn.AppliesToRS.Count); Assert.AreEqual(m_hvoWfics[1], tagAnn.AppliesToRS[0].Hvo, "Something wrong in TextTag AppliesTo[0]."); }
public void CreateAndUpdateSingleFt() { string paraContents = "Das buch ist rot"; string trans = "The book is red"; m_para.Contents.UnderlyingTsString = m_tsf.MakeString(paraContents, m_wsVern); ICmIndirectAnnotation ft = MakeFt(m_para, trans, 0, paraContents.Length); FreeTransEditMonitor monitor = new FreeTransEditMonitor(Cache, m_wsTrans); // BEFORE propChanged! Cache.PropChanged(ft.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0); monitor.LoseFocus(); Assert.AreEqual(1, m_para.TranslationsOC.Count, "monitor should have made a CmTranslation"); Assert.AreEqual(trans, m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text); string trans2 = "The book is green"; ft.Comment.SetAlternative(trans2, m_wsTrans); monitor.Dispose(); // should trigger update. Assert.AreEqual(1, m_para.TranslationsOC.Count, "monitor should not have made another translation"); Assert.AreEqual(trans2, m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text); }
public void MakeTagAnnot_ExistTag_NoOverlap() { // Setup the SelectedWfics property for first tag List <int> tempList = new List <int> (); tempList.Add(m_hvoWfics[0]); tempList.Add(m_hvoWfics[1]); m_tagChild.SelectedWfics = tempList; int hvoInitialTag = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[0]).Hvo; // Setup the SelectedWfics property for second tag List <int> tempList1 = new List <int> (); tempList1.Add(m_hvoWfics[2]); tempList1.Add(m_hvoWfics[3]); tempList1.Add(m_hvoWfics[4]); m_tagChild.SelectedWfics = tempList1; // SUT // Make a second tag annotation with a different possibility pointing to the new Wfics ICmIndirectAnnotation tagSUT = m_tagChild.CallMakeTextTagAnnotation(m_possTagHvos[2]); // Verification // Verify new tag Assert.IsNotNull(tagSUT, "Should have made a Tag."); Assert.AreEqual(m_possTagHvos[2], tagSUT.InstanceOfRAHvo, "Text Tag has wrong possibility Hvo."); Assert.AreEqual(3, tagSUT.AppliesToRS.Count); Assert.AreEqual(m_hvoWfics[2], tagSUT.AppliesToRS[0].Hvo, "Something wrong in new TextTag AppliesTo[0]."); Assert.AreEqual(m_hvoWfics[3], tagSUT.AppliesToRS[1].Hvo, "Something wrong in new TextTag AppliesTo[1]."); Assert.AreEqual(m_hvoWfics[4], tagSUT.AppliesToRS[2].Hvo, "Something wrong in new TextTag AppliesTo[2]."); // The old tag should still exist in the Cache ICmIndirectAnnotation oldtag = AssertTagExists(hvoInitialTag, "Shouldn't have deleted the initial tag."); Assert.AreEqual(m_possTagHvos[0], oldtag.InstanceOfRAHvo, "Text Tag has wrong possibility Hvo."); Assert.AreEqual(2, oldtag.AppliesToRS.Count); Assert.AreEqual(m_hvoWfics[0], oldtag.AppliesToRS[0].Hvo, "Something wrong in old TextTag AppliesTo[0]."); Assert.AreEqual(m_hvoWfics[1], oldtag.AppliesToRS[1].Hvo, "Something wrong in old TextTag AppliesTo[1]."); }
public void NonScriptureText() { IText text = new Text(); Cache.LangProject.TextsOC.Add(text); StText sttext = new StText(); text.ContentsOA = sttext; m_para = new StTxtPara(); sttext.ParagraphsOS.Append(m_para); string paraContents = "Das buch ist rot"; string trans = "The book is red"; m_para.Contents.UnderlyingTsString = m_tsf.MakeString(paraContents, m_wsVern); ICmIndirectAnnotation ft = MakeFt(m_para, trans, 0, paraContents.Length); FreeTransEditMonitor monitor = new FreeTransEditMonitor(Cache, m_wsTrans); // BEFORE propChanged! Cache.PropChanged(ft.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0); monitor.LoseFocus(); Assert.AreEqual(0, m_para.TranslationsOC.Count, "monitor should not make CmTranslation for non-Scripture"); }
/// <summary> /// Make a dependent clause marker at the end of the specified row in the specified column /// for the specified clauses (rows) of the specified type. Caller supplies a marker. /// </summary> /// <param name="rowSrc"></param> /// <param name="colSrc"></param> /// <param name="depClauses"></param> /// <param name="depType"></param> /// <param name="marker"></param> /// <returns></returns> internal ICmIndirectAnnotation MakeDependentClauseMarker(ICmIndirectAnnotation rowSrc, int colSrc, int[] depClauses, string depType, string marker) { foreach (int rowDst in depClauses) { string insert = ""; if (rowDst == depClauses[0]) { insert += " firstDep=\"true\""; } if (rowDst == depClauses[depClauses.Length - 1]) { insert += " endDep=\"true\""; } Cache.SetUnicodeProperty(rowDst, (int)CmAnnotation.CmAnnotationTags.kflidCompDetails, "<ccinfo " + depType + "=\"true\"" + insert + "/>"); } ICmIndirectAnnotation result = MakeColumnAnnotation(colSrc, depClauses, rowSrc); result.Comment.SetAnalysisDefaultWritingSystem(marker); return(result); }
public void CreateAndUpdateOneOfTwoFts() { string pc1 = "Das buch ist rot. "; string pc2 = "Das Madchen ist shon."; string verse1 = "9"; m_para.Contents.UnderlyingTsString = m_tsf.MakeString(pc1 + verse1 + pc2, m_wsVern); string trans1 = "The book is red."; string trans2 = "The girl is beautiful"; ICmIndirectAnnotation ft = MakeFt(m_para, trans1, 0, pc1.Length); ICmBaseAnnotation verseSeg = MakeVerseSegment(m_para, pc1.Length, verse1.Length); ICmIndirectAnnotation ft2 = MakeFt(m_para, trans2, pc1.Length + verse1.Length, pc2.Length); FreeTransEditMonitor monitor = new FreeTransEditMonitor(Cache, m_wsTrans); // BEFORE propChanged! Cache.PropChanged(ft.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0); Cache.PropChanged(ft.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0); Assert.AreEqual(0, m_para.TranslationsOC.Count, "monitor should not have updated for change to same ft."); Cache.PropChanged(ft2.Hvo, (int)CmAnnotation.CmAnnotationTags.kflidComment, 0, 0, 0); Assert.AreEqual(1, m_para.TranslationsOC.Count, "monitor should have updated on changing another property"); Assert.AreEqual(trans1 + " " + verse1 + trans2, m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text, "translation should be correct after changing prop2"); string trans2b = "The girl is pretty."; ft2.Comment.SetAlternative(trans2b, m_wsTrans); // should generate propChanged for same prop. Assert.AreEqual(trans1 + " " + verse1 + trans2, m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text, "Another change to same prop should not produce yet another update"); monitor.Dispose(); Assert.AreEqual(trans1 + " " + verse1 + trans2b, m_para.TranslationsOC.ToList()[0].Translation.GetAlternative(m_wsTrans).Text, "Should get final update on Dispose"); }
internal void CallRemoveMovedFrom(int icolActual, int icolMovedFrom, ICmIndirectAnnotation row) { RemoveMovedFrom(new ChartLocation(icolActual, row), new ChartLocation(icolMovedFrom, row)); }
int[] m_allColumns; // The complete array of columns in the chart #endregion public CChartSentenceElements(ChartLocation cellClicked, ICmIndirectAnnotation[] eligRows, int[] hvoEligColumns) { m_clickedCell = cellClicked; m_affectedCcas = new List<int>(); m_eligibleRows = eligRows; m_eligibleColumns = hvoEligColumns; m_allColumns = m_eligibleColumns; m_rows = null; m_cols = null; }
public ChartLocation(int icol, ICmIndirectAnnotation row) { m_cellColumnIndex = icol; m_cellRow = row; }
/// <summary> /// The test version doesn't want anything to do with views (which the superclass version does). /// </summary> /// <param name="tagAnn"></param> protected override Set <int> CacheTagString(ICmIndirectAnnotation tagAnn) { return(null); }
private void VerifyMakeMovedWithCollidingMarker(ICmIndirectAnnotation row0, int[] allParaWfics, NotifyChangeSpy spy, int cExpectCSelect) { VerifyRow(0, "1a", 3); VerifyCca(0, 0, m_allColumns[1], new int[] { allParaWfics[0] }, ""); ICmIndirectAnnotation cca0_3 = m_chart.RowsRS[0].AppliesToRS[2] as ICmIndirectAnnotation; VerifyCca(0, 1, m_allColumns[1], new int[] { cca0_3.Hvo }, ConstituentChartLogic.FTO_MovedTextAfter); VerifyCca(0, 2, m_allColumns[3], new int[] { allParaWfics[1] }, ""); Assert.AreEqual(cExpectCSelect, m_mockRibbon.CSelectFirstCalls); AssertUsedAnnotations(allParaWfics, 2); Assert.AreEqual(1, m_chart.RowsRS.Count, "should not add rows"); // Verify various PropChanged calls. VerifyAnnotationListChange(allParaWfics, spy, 2, 1); }
private void InitializeCca(ICmAnnotation cca, int icol, ICmIndirectAnnotation row) { cca.InstanceOfRAHvo = m_allColumns[icol]; row.AppliesToRS.Append(cca); cca.AnnotationTypeRA = CmAnnotationDefn.ConstituentChartAnnotation(Cache); }
/// <summary> /// Caches a possibility label for each Wfic that a tag appliesTo. /// </summary> /// <param name="tagAnn"></param> /// <returns>set of xfics for which a tag was cached.</returns> internal Set<int> CacheTagString(ICmIndirectAnnotation tagAnn) { Set<int> xficsTagged = new Set<int>(); ICmPossibility tagPossibility = tagAnn.InstanceOfRA as ICmPossibility; ITsString label; if (tagPossibility == null) label = TsStrFactoryClass.Create().MakeString("", Cache.LangProject.DefaultAnalysisWritingSystem); else label = tagPossibility.Abbreviation.BestAnalysisAlternative; int chvoArray = tagAnn.AppliesToRS.Count; // use 'for' loop because we need to know when we're at the beginning // and end of the loop for(int i=0; i < chvoArray; i++) { int hvoXfic = tagAnn.AppliesToRS[i].Hvo; int clen = label.Length; ITsStrBldr strBldr = label.GetBldr(); if (i == 0) // First wfic for this tag. clen = StartTagSetup(clen, strBldr); else { // Until someone has a better idea, only show the label on the first wfic. clen = 0; strBldr.Clear(); } if (i == chvoArray - 1) // Last wfic for this tag. { clen = EndTagSetup(clen, strBldr); } Cache.VwCacheDaAccessor.CacheStringProp(hvoXfic, TextTagAnnotFlid, strBldr.GetString()); xficsTagged.Add(hvoXfic); } return xficsTagged; }
internal void Run(bool fMakeSelectionInNewFreeformAnnotation) { IVwSelection sel = null; if (m_site is InterlinDocChild) { sel = (m_site as InterlinDocChild).MakeSandboxSel(); } // If there's no sandbox selection, there may be one in the site itself, perhaps in another // free translation. if (sel == null) { sel = m_site.RootBox.Selection; } if (sel == null) { return; // Enhance JohnT: give an error, or disable the command. } int cvsli = sel.CLevels(false); cvsli--; // CLevels includes the string property itself, but AllTextSelInfo doesn't need it. // Out variables for AllTextSelInfo. int ihvoRoot; int tagTextProp; int cpropPrevious; int ichAnchor; int ichEnd; int ws; bool fAssocPrev; int ihvoEnd; ITsTextProps ttpBogus; // Main array of information retrived from sel that made combo. SelLevInfo[] rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli, out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd, out ws, out fAssocPrev, out ihvoEnd, out ttpBogus); // Identify the segment. // This is important because although we are currently displaying just an StTxtPara, // eventually it might be part of a higher level structure. We want this to work // no matter how much higher level structure there is. int itagSegments = -1; for (int i = rgvsli.Length; --i >= 0;) { if (rgvsli[i].tag == m_vc.ktagParaSegments) { itagSegments = i; break; } } if (itagSegments == -1) { return; // Enhance JohnT: throw? disable command? Give an error? } int hvoSeg = rgvsli[itagSegments].hvo; if (m_fdoCache.IsDummyObject(hvoSeg)) { // we need to convert this into a real segment before proceeding. ICmBaseAnnotation cbaReal = CmBaseAnnotation.ConvertBaseAnnotationToReal(m_fdoCache, hvoSeg); hvoSeg = cbaReal != null ? cbaReal.Hvo : 0; rgvsli[itagSegments].hvo = hvoSeg; } ICmIndirectAnnotation ann = AddFreeformAnnotation(hvoSeg, m_hvoType); // If necessary (e.g., we just added a previously invisible FF annotation), // Reconstruct the root box. Otherwise, a simple PropChanged will do. if (m_fNeedReconstruct) { m_site.RootBox.Reconstruct(); // m_site.Invalidate(); // m_site.Update(); // necessary to get a lazy } if (!fMakeSelectionInNewFreeformAnnotation) { return; } // Now try to make a new selection in the FF we just made. // The elements of rgvsli from itagSegments onwards form a path to the segment. // In the segment we want the freeform propery, specifically the new one we just made. // We want to select at the start of it. SelLevInfo[] rgvsliNew = new SelLevInfo[rgvsli.Length - itagSegments + 1]; for (int i = 1; i < rgvsliNew.Length; i++) { rgvsliNew[i] = rgvsli[i + itagSegments - 1]; } // Work out how many freeforms are DISPLAYED before the (first occurrence of the) one we want to select. int ihvo = 0; Dictionary <int, List <int> > dict = m_vc.OrganizeFfAnnotations(hvoSeg); for (int i = m_choices.FirstFreeformIndex; i < m_choices.Count;) { int hvoAnnType = m_vc.SegDefnFromFfFlid(m_choices[i].Flid); List <int> annotations = null; if (dict.ContainsKey(hvoAnnType)) { annotations = dict[hvoAnnType]; } if (hvoAnnType == m_hvoType) { ihvo += annotations.IndexOf(ann.Hvo); break; // And that's where we want our selection!! } // Adjacent WSS of the same annotation count as only ONE object in the display. // So we advance i over as many items in m_choices as there are adjacent Wss // of the same flid. i += m_choices.AdjacentWssAtIndex(i).Length; // But each time we display this flid, we display ALL the objects, // so advance ihvo by the number of annotations of the type. int chvoAnn = annotations == null ? 0 : annotations.Count; ihvo += chvoAnn; } rgvsliNew[0].ihvo = ihvo; rgvsliNew[0].tag = m_vc.ktagSegFF; rgvsliNew[0].cpropPrevious = 0; m_site.RootBox.MakeTextSelInObj(0, rgvsliNew.Length, rgvsliNew, 0, null, true, true, false, false, true); }
/// <summary> /// The test version doesn't want anything to do with views (which the superclass version does). /// </summary> /// <param name="tagAnn"></param> protected override Set<int> CacheTagString(ICmIndirectAnnotation tagAnn) { return null; }
internal void SetRows(ICmIndirectAnnotation[] items) { // Convert ICmIndirectAnnotations to RowMenuItems RowMenuItem[] rows = new RowMenuItem[items.Length]; for (int i = 0; i < items.Length; i++) rows[i] = new RowMenuItem(items[i]); m_rowsCombo.Items.Clear(); m_rowsCombo.Items.AddRange(rows); }
internal void CallRemoveMovedFromDiffRow(int icolActual, int icolMovedFrom, ICmIndirectAnnotation rowActual, ICmIndirectAnnotation rowMovedFrom) { RemoveMovedFrom(new ChartLocation(icolActual, rowActual), new ChartLocation(icolMovedFrom, rowMovedFrom)); }
internal void VerifyChangeColumnEvent(ICmAnnotation[] ccasToMove, int hvoNewCol, ICmIndirectAnnotation row) { object[] event1 = VerifyEventExists("change column", 3); Assert.AreEqual(ccasToMove, event1[1] as ICmAnnotation[]); Assert.AreEqual(hvoNewCol, event1[2]); Assert.AreEqual(row.Hvo, (event1[3] as ICmIndirectAnnotation).Hvo); }
protected ChartLocation MakeLocObj(ICmIndirectAnnotation row, int icol) { return new ChartLocation(icol, row); }
internal ICmBaseAnnotation MakeMarkerAnnotation(int icol, ICmIndirectAnnotation row, ICmPossibility marker) { CmBaseAnnotation cba = MakeBaseAnnotation(); cba.BeginObjectRA = marker; InitializeCca(cba, icol, row); return cba; }
private IVwSelection MakeRowSelection(ICmIndirectAnnotation row, bool fInstall) { SelLevInfo[] rgvsli = new SelLevInfo[1]; rgvsli[0].ihvo = m_logic.IndexOfRow(row.Hvo); // specifies which row. rgvsli[0].tag = (int)DsConstChart.DsConstChartTags.kflidRows; IVwSelection sel = null; try { sel = RootBox.MakeTextSelInObj(0, 1, rgvsli, 0, null, false, false, false, true, fInstall); } catch (Exception e) { Debug.WriteLine(e.StackTrace); return null; } return sel; }
public ChartLocation MakeLocObj(int icol, ICmIndirectAnnotation row) { return new ChartLocation(icol, row); }
/// <summary> /// Figure out what columns should be available, given a selected row. /// </summary> /// <returns></returns> internal int[] GetColumnChoices(ICmIndirectAnnotation row) { if (row.Hvo != SentElem.GetOriginRow.Hvo) { CollectAllColumnsToCombo(); return SentElem.AllChartCols; } int ccols = SentElem.AllChartCols.Length; int icurCol = SentElem.GetOriginColumnIndex; if (Prepose) { // Collect columns following clicked one ccols = ccols - icurCol - 1; icurCol++; } else { // Collect columns preceding clicked one ccols = icurCol; icurCol = 0; } int[] result = new int[Math.Max(0, ccols)]; for (int i = 0; i < ccols; i++) { result[i] = SentElem.AllChartCols[i + icurCol]; } return result; }
public override void ChangeRow(int[] ccasToMove, ICmIndirectAnnotation rowSrc, ICmIndirectAnnotation rowDst, int srcIndex, int dstIndex) { if (m_fRecordBasicEdits) m_events.Add(new object[] { "change row", ccasToMove, rowSrc, rowDst, srcIndex, dstIndex }); else base.ChangeRow(ccasToMove, rowSrc, rowDst, srcIndex, dstIndex); }
public override void ChangeColumn(ICmAnnotation[] ccasToMove, int hvoNewCol, ICmIndirectAnnotation row) { if (m_fRecordBasicEdits) m_events.Add(new object[] { "change column", ccasToMove, hvoNewCol, row }); else base.ChangeColumn(ccasToMove, hvoNewCol, row); }
// Make a column annotation for the specified column that groups the specified words // and append to the specified row. internal CmIndirectAnnotation MakeColumnAnnotation(int icol, int[] words, ICmIndirectAnnotation row) { CmIndirectAnnotation cca = MakeIndirectAnnotation(); for (int i = 0; i < words.Length; i++) cca.AppliesToRS.Append(words[i]); InitializeCca(cca, icol, row); return cca; }
public override void DeleteCcas(ICmIndirectAnnotation row, int ihvo, int chvo) { if (m_fRecordBasicEdits) m_events.Add(new object[] { "delete ccas", row, ihvo, chvo }); else base.DeleteCcas(row, ihvo, chvo); }
/// <summary> /// Sets the member variable for the clicked cell's RowColMenuItem. /// Call SetupParameterObject() to install it. /// </summary> /// <param name="rowLabel"></param> /// <param name="row"></param> /// <param name="icolSrc"></param> void SetClickedCell(ICmIndirectAnnotation row, int icolSrc) { m_origCell = new ChartLocation(icolSrc, row); }
public override void ChangeCca(int[] wficsToMove, ICmIndirectAnnotation ccaSrc, ICmIndirectAnnotation ccaDst, int srcIndex, int dstIndex) { if (m_fRecordBasicEdits) m_events.Add(new object[] { "change parent", wficsToMove, ccaSrc, ccaDst, srcIndex, dstIndex }); else base.ChangeCca(wficsToMove, ccaSrc, ccaDst, srcIndex, dstIndex); }
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. } }
/// <summary> /// Make a dependent clause marker at the end of the specified row in the specified column /// for the specified clauses (rows) of the specified type. Caller supplies a marker. /// </summary> /// <param name="rowSrc"></param> /// <param name="colSrc"></param> /// <param name="depClauses"></param> /// <param name="depType"></param> /// <param name="marker"></param> /// <returns></returns> internal ICmIndirectAnnotation MakeDependentClauseMarker(ICmIndirectAnnotation rowSrc, int colSrc, int[] depClauses, string depType, string marker) { foreach (int rowDst in depClauses) { string insert = ""; if (rowDst == depClauses[0]) insert += " firstDep=\"true\""; if (rowDst == depClauses[depClauses.Length - 1]) insert += " endDep=\"true\""; Cache.SetUnicodeProperty(rowDst, (int)CmAnnotation.CmAnnotationTags.kflidCompDetails, "<ccinfo " + depType + "=\"true\"" + insert + "/>"); } ICmIndirectAnnotation result = MakeColumnAnnotation(colSrc, depClauses, rowSrc); result.Comment.SetAnalysisDefaultWritingSystem(marker); return result; }
protected ChartLocation MakeLocObj(ICmIndirectAnnotation row, int icol) { return(new ChartLocation(icol, row)); }
/// <summary> /// Protected virtual so the testing subclass doesn't have to know about Views. /// </summary> /// <param name="tagAnn"></param> protected virtual Set<int> CacheTagString(ICmIndirectAnnotation tagAnn) { // Cache the new tagging string in our dummy virtual property (TagAnnotListId) // and call PropChanged return (m_vc as InterlinTaggingVc).CacheTagString(tagAnn); }