Beispiel #1
0
        internal void CallMergeCellContents(IConstChartRow rowSrc, int icolSrc, IConstChartRow rowDst, int icolDst, bool forward)
        {
            var srcCell = new ChartLocation(rowSrc, icolSrc);
            var dstCell = new ChartLocation(rowDst, icolDst);

            MergeCellContents(srcCell, dstCell, forward);
        }
Beispiel #2
0
        /// <summary>
        /// A chart location is the same as another if its row Hvo and column index are the same.
        /// Overriding Equals complained that I didn't override GetHashCode().
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool IsSameLocation(object obj1)
        {
            if (!(obj1 is ChartLocation))
            {
                return(false);
            }
            ChartLocation obj = obj1 as ChartLocation;

            if (this.IsValidLocation)
            {
                if (!obj.IsValidLocation)
                {
                    return(false);
                }
                // Both ChartLocation objects are 'valid', check for same location.
                return(this.RowAnn.Hvo == obj.RowAnn.Hvo && this.ColIndex == obj.ColIndex);
            }
            else
            {
                if (obj.IsValidLocation)
                {
                    return(false);
                }
                // Both ChartLocation objects are 'invalid', by definition they are the same location
                // even if they are 'invalid' for different reasons.
                return(true);
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 internal void VerifyMergeCellsEvent(ChartLocation srcCell, ChartLocation dstCell, bool forward)
 {
     //m_events.Add(new object[] { "merge cell contents", srcCell, dstCell, forward });
     object[] event1 = VerifyEventExists("merge cell contents", 3);
     Assert.IsTrue(srcCell.IsSameLocation(event1[1]));
     Assert.IsTrue(dstCell.IsSameLocation(event1[2]));
     Assert.AreEqual(forward, event1[3]);
 }
Beispiel #5
0
        public override void Exit()
        {
            m_origCell = null;
            m_sentElem = null;
            m_chart    = null;
            m_cclogic  = null;

            base.Exit();
        }
		internal void CallGetWordGroupCellsBorderingChOrph(AnalysisOccurrence occurrence,
			out ChartLocation precCell, out ChartLocation follCell)
		{
			var iPara = m_ccl.CallGetParaIndexForOccurrence(occurrence);
			Assert.Greater(iPara, -1, "Can't get ChOrph paragraph index.");
			var offset = occurrence.GetMyBeginOffsetInPara();
			Assert.Greater(offset, -1, "Can't get ChOrph offset.");
			m_ccl.GetWordGroupCellsBorderingChOrph(iPara, offset, out precCell, out follCell);
		}
		public override void Exit()
		{
			m_origCell = null;
			m_sentElem = null;
			m_chart = null;
			m_cclogic = null;

			base.Exit();
		}
		internal void CallGetWficCellsBorderingChOrph(int hvoChOrph, out ChartLocation precCell, out ChartLocation follCell)
		{
			int iPara, offset;
			iPara = m_ccl.CallGetWficParaIndex(hvoChOrph);
			Assert.Greater(iPara, -1, "Can't get ChOrph paragraph index.");
			offset = m_ccl.CallGetBeginOffset(hvoChOrph);
			Assert.Greater(offset, -1, "Can't get ChOrph offset.");
			m_ccl.GetWficCellsBorderingChOrph(iPara, offset, out precCell, out follCell);
		}
Beispiel #9
0
        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;
        }
Beispiel #10
0
        ICmPossibility[] m_allColumns;      // The complete array of columns in the chart

        #endregion

        public CChartSentenceElements(ChartLocation cellClicked, IConstChartRow[] eligRows, ICmPossibility[] eligColumns)
        {
            m_clickedCell      = cellClicked;
            AffectedWordGroups = new List <IConstChartWordGroup>();
            m_eligibleRows     = eligRows;
            m_eligibleColumns  = eligColumns;
            m_allColumns       = m_eligibleColumns;
            m_rows             = null;
            m_cols             = null;
        }
Beispiel #11
0
 protected override void MergeCellContents(ChartLocation srcCell, ChartLocation dstCell, bool forward)
 {
     if (m_fRecordMergeCellContents)
     {
         m_events.Add(new object[] { "merge cell contents", srcCell, dstCell, forward });
     }
     else
     {
         base.MergeCellContents(srcCell, dstCell, forward);
     }
 }
Beispiel #12
0
		public void CellContextMissingMarker_OtherMarkerExistsInNonSVColumn()
		{
			const int icol = 0; // Empty Non-SV column
			CmIndirectAnnotation row0 = m_helper.MakeRow1a();
			ChartLocation cloc = MakeLocObj(row0, icol);
			m_helper.MakeMarkerAnnotation(icol, row0, m_helper.GetAMarker()); // make an arbitrary marker
			ContextMenuStrip strip = m_logic.MakeCellContextMenu(cloc);
			ToolStripMenuItem itemMissing = AssertHasMenuWithText(strip.Items, DiscourseStrings.ksMarkMissingItem, 0);
			Assert.IsFalse(itemMissing.Checked, "Missing item in cell with other marker should not be checked.");
			AssertHasNoMenuWithText(strip.Items, DiscourseStrings.ksMoveMenuItem); // can't move possibility markers
		}
Beispiel #13
0
		public void CellContextMissingMarker_OtherMarkerExistsInSubjectColumn()
		{
			const int icol = 2; // Subject (special) column
			CmIndirectAnnotation row0 = m_helper.MakeRow1a();
			ChartLocation cloc = MakeLocObj(row0, icol);
			m_helper.MakeMarkerAnnotation(icol, row0, m_helper.GetAMarker()); // make an arbitrary marker
			ContextMenuStrip strip = m_logic.MakeCellContextMenu(cloc);
			// Should not be able to add a Missing Marker, since this this an AutoMissingMarker column.
			AssertHasNoMenuWithText(strip.Items, DiscourseStrings.ksMarkMissingItem);
			AssertHasNoMenuWithText(strip.Items, DiscourseStrings.ksMoveMenuItem); // can't move possibility markers
		}
Beispiel #14
0
		public void CellContextMissingMarker_ExistsInNonSVColumn()
		{
			const int icol = 0; // Empty Non-SV column
			CmIndirectAnnotation row0 = m_helper.MakeRow1a();
			ChartLocation cloc = MakeLocObj(row0, icol);
			m_helper.MakeColumnAnnotation(cloc.ColIndex, new int[0], cloc.RowAnn); // missing marker
			ContextMenuStrip strip = m_logic.MakeCellContextMenu(cloc);
			ToolStripMenuItem itemMissing = AssertHasMenuWithText(strip.Items, DiscourseStrings.ksMarkMissingItem, 0);
			Assert.IsTrue(itemMissing.Checked, "Missing item in cell with missing marker should be checked.");
			AssertHasNoMenuWithText(strip.Items, DiscourseStrings.ksMoveMenuItem); // can't move missing marker
		}
Beispiel #15
0
		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);
		}
Beispiel #16
0
		public void TestCcasInCell_None()
		{
			// Need to make sure we get a valid index out even when there are no CCAs
			// in the given cell. (As opposed to the false information given by the comment before.)
			int[] allParaWfics = m_helper.MakeAnnotationsUsedN(1);
			CmIndirectAnnotation row0 = m_helper.MakeFirstRow();
			CmIndirectAnnotation cca0_0 = m_helper.MakeColumnAnnotation(0, new int[] { allParaWfics[0] }, row0);
			CmIndirectAnnotation cca0_2 = m_helper.MakeColumnAnnotation(2, new int[] { allParaWfics[1], allParaWfics[2] }, row0);
			CmIndirectAnnotation cca0_2b = m_helper.MakeColumnAnnotation(2, new int[] { allParaWfics[3] }, row0);
			CmIndirectAnnotation cca0_4 = m_helper.MakeColumnAnnotation(4, new int[] { allParaWfics[4] }, row0);
			ChartLocation cell = MakeLocObj(row0, 3);
			List<ICmAnnotation> ccaList;
			int index_actual;

			// SUT; mostly interested in the index, but verify that the list is empty too.
			ccaList = m_logic.CcasInCell(cell, out index_actual);
			Assert.AreEqual(3, index_actual, "Should be at index 3 in row.AppliesTo.");
			Assert.IsEmpty(ccaList, "Shouldn't be any CCAs in this cell (should be empty list).");
		}
Beispiel #17
0
 protected override void CreateTestData()
 {
     base.CreateTestData();
     m_cclogic        = new TestCCLogic(Cache, m_chart, m_stText);
     m_cclogic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
     m_helper.Logic   = m_cclogic;
     m_template       = m_helper.MakeTemplate(out m_allColumns);
     // Note: do this AFTER creating the template, which may also create the DiscourseData object.
     m_chart    = m_helper.SetupAChart();
     m_origCell = null;
     // Test must fill in the ClickedCell in the CChartSentenceElements object
     m_eligCols = m_allColumns.ToArray();
     // CChartSentenceElements always starts with all columns
     m_eligRows = null;
     // Test must fill in EligibleRows in the CChartSentenceElements object
     m_sentElem         = new CChartSentenceElements(m_origCell, m_eligRows, m_eligCols);
     m_dlgLogicPrepose  = new AdvancedMTDialogLogic(Cache, true, m_sentElem);
     m_dlgLogicPostpose = new AdvancedMTDialogLogic(Cache, false, m_sentElem);
     // create one each direction; test both
 }
		protected override void CreateTestData()
		{
			base.CreateTestData();
			m_cclogic = new TestCCLogic(Cache, m_chart, m_stText);
			m_cclogic.Ribbon = m_mockRibbon = new MockRibbon(Cache, m_stText.Hvo);
			m_helper.Logic = m_cclogic;
			m_template = m_helper.MakeTemplate(out m_allColumns);
			// Note: do this AFTER creating the template, which may also create the DiscourseData object.
			m_chart = m_helper.SetupAChart();
			m_origCell = null;
			// Test must fill in the ClickedCell in the CChartSentenceElements object
			m_eligCols = m_allColumns.ToArray();
			// CChartSentenceElements always starts with all columns
			m_eligRows = null;
			// Test must fill in EligibleRows in the CChartSentenceElements object
			m_sentElem = new CChartSentenceElements(m_origCell, m_eligRows, m_eligCols);
			m_dlgLogicPrepose = new AdvancedMTDialogLogic(Cache, true, m_sentElem);
			m_dlgLogicPostpose = new AdvancedMTDialogLogic(Cache, false, m_sentElem);
			// create one each direction; test both
		}
Beispiel #19
0
		internal int CallFindIndexOfCcaInLaterColumn(ChartLocation targetCell)
		{
			return FindIndexOfCcaInLaterColumn(targetCell);
		}
Beispiel #20
0
		internal bool CallIsMarkedAsMovedFrom(ChartLocation actualCell, int icolMovedFrom)
		{
			return IsMarkedAsMovedFrom(actualCell, icolMovedFrom);
		}
Beispiel #21
0
 internal void CallRemoveDepClause(ChartLocation srcCell)
 {
     RemoveDepClause(srcCell);
 }
Beispiel #22
0
		internal List<ICmIndirectAnnotation> CallCollectEligRows(ChartLocation cell, bool fPrepose)
		{
			return CollectEligibleRows(cell, fPrepose);
		}
		public void RemoveDepClause()
		{
			int[] allParaWfics = m_helper.MakeAnnotationsUsedN(5);
			CmIndirectAnnotation row0 = m_helper.MakeRow1a();
			CmIndirectAnnotation row1 = m_helper.MakeSecondRow();
			CmIndirectAnnotation row2 = m_helper.MakeRow(m_chart, "1c");
			CmIndirectAnnotation cca0_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[0] }, row0);
			CmIndirectAnnotation cca1_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[1] }, row1);
			CmIndirectAnnotation cca1_2 = m_helper.MakeColumnAnnotation(2, new int[] { allParaWfics[2], allParaWfics[3] }, row1);
			CmIndirectAnnotation cca2_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[4] }, row2);
			ICmIndirectAnnotation cca0_2 = m_helper.MakeDependentClauseMarker(row0, 2,
				new int[] { row1.Hvo, row2.Hvo }, "dependent", "1b-1c");
			ChartLocation cell = new ChartLocation(2, row0);

			StartCheckingDataAccess();

			// Delete the marker that makes 1b-1c a dependent clause
			m_sdaChecker.ExpectDeleteObjects(new int[] { cca0_2.Hvo });
			m_sdaChecker.ExpectVector(row0.Hvo, kflidAppliesTo, new int[] { cca0_1.Hvo },
				"should have deleted clause marker from row0");
			// It would also be fine to clear these fields!
			m_sdaChecker.ExpectUnicode(row1.Hvo, kflidCompDetails, "<ccinfo dependent=\"false\" firstDep=\"false\" />",
				"Should have cleared dependent and firstDep flags on row 1");
			m_sdaChecker.ExpectUnicode(row2.Hvo, kflidCompDetails, "<ccinfo dependent=\"false\" endDep=\"false\" />",
				"Should have cleared dependent and endDep flags on row 2");

			m_logic.CallRemoveDepClause(cell);
			m_sdaChecker.VerifyExpectedChanges();

			(Cache.ActionHandlerAccessor as MockActionHandler).VerifyUndoRedoText(
				ConstituentChartLogic.FTO_UndoRemoveClauseMarker, ConstituentChartLogic.FTO_RedoRemoveClauseMarker,
				"should undo/redo Remove Clause Marker");
		}
		public void MoveWordForwardGroupToEmpty()
		{
			int[] allParaWfics = m_helper.MakeAnnotationsUsedN(2);
			CmIndirectAnnotation row0 = m_helper.MakeFirstRow();
			CmIndirectAnnotation cca0_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[0], allParaWfics[1] }, row0);
			ChartLocation cell = new ChartLocation(1, row0);
			StartCheckingDataAccess();
			m_sdaChecker.ExpectCreateObjectInCollection(Cache.LangProject.Hvo, kflidAnnotations, 1,
				"should create one new CCA");
			int newCca = m_sdaChecker.GetNewObjectId();
			m_sdaChecker.ExpectVector(row0.Hvo, kflidAppliesTo, new int[] { cca0_1.Hvo, newCca },
				"should have made new CCA at end of row 0");
			m_sdaChecker.ExpectVector(newCca, kflidAppliesTo, new int[] { allParaWfics[1] },
				"new CCA should contain moved word");
			m_sdaChecker.ExpectAtomic(newCca, kflidInstanceOf, m_logic.AllMyColumns[2], "should set column of new CCA");
			m_sdaChecker.ExpectAtomic(newCca, kflidAnnotationType, CmAnnotationDefn.ConstituentChartAnnotation(Cache).Hvo,
				"should set annotation type of new CCA");
			m_sdaChecker.ExpectVector(cca0_1.Hvo, kflidAppliesTo, new int[] { allParaWfics[0] },
				"should have moved word out of cell 1");
			m_sdaChecker.ExpectVector(newCca, kflidAppliesTo, new int[] { allParaWfics[1] },
				"should have moved word into cell 2");
			m_logic.MoveWordForward(cell);
			m_sdaChecker.VerifyExpectedChanges();
			(Cache.ActionHandlerAccessor as MockActionHandler).VerifyUndoRedoText(
				ConstituentChartLogic.FTO_UndoMoveWord, ConstituentChartLogic.FTO_RedoMoveWord, "should be undo move word");
		}
		public void MoveWordForwardDepClauseToNextRow()
		{
			// should delete 2a, renumber 2b -> 2a
			int ilastCol = m_logic.AllMyColumns.Length - 1;
			int[] allParaWfics = m_helper.MakeAnnotationsUsedN(3);
			CmIndirectAnnotation row0 = m_helper.MakeFirstRow();
			ConstituentChartLogic.SetFeature(Cache.MainCacheAccessor, row0.Hvo, ConstituentChartLogic.EndSentFeatureName, true);
			CmIndirectAnnotation row1 = m_helper.MakeRow("2a");
			CmIndirectAnnotation row2 = m_helper.MakeRow("2b");
			CmIndirectAnnotation cca0_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[0] }, row0);
			CmIndirectAnnotation cca1_last = m_helper.MakeColumnAnnotation(ilastCol,
				new int[] { allParaWfics[1] }, row1);
			ICmIndirectAnnotation cca2_2 = m_helper.MakeDependentClauseMarker(row2, 2, new int[] { row1.Hvo }, "dependent", "2a")
				as CmIndirectAnnotation;
			ChartLocation cell = new ChartLocation(ilastCol, row1);
			StartCheckingDataAccess();
			m_sdaChecker.ExpectDeleteObjects(new int[] { row1.Hvo, cca2_2.Hvo }); // should delete empty row and dep marker
			m_sdaChecker.ExpectAtomic(cca1_last.Hvo, kflidInstanceOf, m_logic.AllMyColumns[0],
				"should have moved word from last col to first of next row");
			m_sdaChecker.ExpectVector(m_chart.Hvo, kflidRows, new int[] { row0.Hvo, row2.Hvo },
				"should have deleted empty row");
			m_sdaChecker.ExpectVector(row2.Hvo, kflidAppliesTo, new int[] { cca1_last.Hvo },
				"should have deleted dep marker and added word to row");
			m_sdaChecker.ExpectStringAlt(row2.Hvo, kflidComment, Cache.DefaultAnalWs, Cache.MakeAnalysisTss("2"),
				"should have modified row number");
			m_logic.MoveWordForward(cell);
			m_sdaChecker.VerifyExpectedChanges();
			(Cache.ActionHandlerAccessor as MockActionHandler).VerifyUndoRedoText(
				ConstituentChartLogic.FTO_UndoMoveWord, ConstituentChartLogic.FTO_RedoMoveWord, "should be undo move word");
		}
Beispiel #26
0
		/// <summary>
		/// Get info about which cell the user clicked in.
		/// </summary>
		/// <param name="e"></param>
		/// <param name="clickedCell"></param>
		/// <param name="irow"></param>
		/// <returns>true if it is a template column, or false if some other column (Notes?)</returns>
		private bool GetCellInfo(MouseEventArgs e, out ChartLocation clickedCell, out int irow)
		{
			clickedCell = null; // in case of premature 'return'
			irow = -1;
			int icol = -1;
			if (m_hvoChart == 0 || m_AllColumns == null || e.Y > m_rootb.Height)
				return false;
			Point pt;
			Rectangle rcSrcRoot;
			Rectangle rcDstRoot;
			using (new HoldGraphics(this))
			{
				pt = PixelToView(new Point(e.X, e.Y));
				GetCoordRects(out rcSrcRoot, out rcDstRoot);
				IVwSelection sel = RootBox.MakeSelAt(pt.X, pt.Y, rcSrcRoot, rcDstRoot, false);
				if (sel == null)
					return false;
				TextSelInfo info = new TextSelInfo(sel);
				if (info.Levels(false) < 2)
					return false;
				irow = GetIndexOfTopLevelObject(info, false);
				IDsConstChart chart = DsConstChart.CreateFromDBObject(Cache, m_hvoChart);
				Debug.Assert(irow >= 0 && irow < chart.RowsRS.Count);
				icol = m_logic.GetColumnFromPosition(e.X, m_chart.ColumnPositions) - 1;
				clickedCell = new ChartLocation(icol, chart.RowsRS[irow]);
				// return true if we clicked on a valid template column (other than notes)
				// return false if we clicked on an 'other' column, like notes or row number?
				return icol > -1 && icol < m_AllColumns.Length;
			}
		}
		public void MoveWordForwardGroupToEmpty()
		{
			var allParaOccurrences = m_helper.MakeAnalysesUsedN(2);
			var row0 = m_helper.MakeFirstRow();
			var cellPart0_1 = m_helper.MakeWordGroup(row0, 1, allParaOccurrences[0], allParaOccurrences[1]);
			var cell = new ChartLocation(row0, 1);
			var nextHvo = cellPart0_1.Hvo + 1;
			EndSetupTask(); // SUT has its own UOW

			// SUT
			m_logic.MoveWordForward(cell);

			// Verify
			var newWordGrp = VerifyCreatedCellPart(nextHvo,
				"Should have made new WordGroup at end of row 0") as IConstChartWordGroup;
			VerifyRowContents(0, new IConstituentChartCellPart[] { cellPart0_1, newWordGrp });
			// should have moved word out of cell 1
			VerifyWordGroup(0, 0, m_allColumns[1], new List<AnalysisOccurrence> { allParaOccurrences[0] });
			// new WordGroup should contain moved word
			VerifyWordGroup(0, 1, m_allColumns[2], new List<AnalysisOccurrence> { allParaOccurrences[1] });
		}
		public void MoveWordForwardDepClauseToNextRow()
		{
			// should delete 2a, renumber 2b -> 2
			var ilastCol = m_logic.AllMyColumns.Length - 1;
			var allParaOccurrences = m_helper.MakeAnalysesUsedN(3);
			var row0 = m_helper.MakeFirstRow();
			row0.EndSentence = true;
			var row1 = m_helper.MakeRow("2a");
			var row2 = m_helper.MakeRow("2b");
			m_helper.MakeWordGroup(row0, 1, allParaOccurrences[0], allParaOccurrences[0]);
			var cellPart1_last = m_helper.MakeWordGroup(row1, ilastCol, allParaOccurrences[1], allParaOccurrences[1]);
			var cellPart2_2 = m_helper.MakeDependentClauseMarker(row2, 2, new [] { row1 }, ClauseTypes.Dependent);
			var cell = new ChartLocation(row1, ilastCol);
			EndSetupTask(); // SUT has its own UOW

			// SUT
			m_logic.MoveWordForward(cell);

			// Verify
			VerifyDeletedHvos(new[] { row1.Hvo , cellPart2_2.Hvo }, "Should delete empty row and dep marker; Hvo {0} still exists!");
			// Should have deleted the empty row from the chart
			VerifyChartRows(m_chart, new[] { row0, row2 });
			// Should have deleted dep marker and added word to row
			VerifyRowContents(1, new [] { cellPart1_last });
			VerifyRowNumber("2", row2, "Should have modified row number");
			// should have moved word from last col to first of next row
			VerifyWordGroup(1, 0, m_allColumns[0], new List<AnalysisOccurrence> { allParaOccurrences[1] });
		}
		public void RemoveDepClause()
		{
			var allParaOccurrences = m_helper.MakeAnalysesUsedN(5);
			var row0 = m_helper.MakeRow1a();
			var row1 = m_helper.MakeSecondRow();
			var row2 = m_helper.MakeRow(m_chart, "1c");
			var cellPart0_1 = m_helper.MakeWordGroup(row0, 1, allParaOccurrences[0], allParaOccurrences[0]);
			m_helper.MakeWordGroup(row1, 1, allParaOccurrences[1], allParaOccurrences[1]);
			m_helper.MakeWordGroup(row1, 2, allParaOccurrences[2], allParaOccurrences[3]);
			m_helper.MakeWordGroup(row2, 1, allParaOccurrences[4], allParaOccurrences[4]);
			var cellPart0_2 = m_helper.MakeDependentClauseMarker(row0, 2,
				new [] { row1, row2 }, ClauseTypes.Dependent);
			var cell = new ChartLocation(row0, 2);
			EndSetupTask(); // SUT has its own UOW

			// SUT
			// Delete the marker that makes 1b-1c a dependent clause
			m_logic.CallRemoveDepClause(cell);

			// Verify
			VerifyDeletedHvos(new[] {cellPart0_2.Hvo},
				"Should have deleted clause marker from row0; Hvo {0} still exists!");
			VerifyRowContents(0, new[] { cellPart0_1 }); // Should have deleted clause marker from row0
			// It would also be fine to clear these fields!
			// Should have cleared dependent and firstDep flags on row 1
			VerifyRowDetails(1, ClauseTypes.Normal, false, false, false, false);
			// Should have cleared dependent and endDep flags on row 2
			VerifyRowDetails(2, ClauseTypes.Normal, false, false, false, false);
		}
		public void MoveWordFwdPutsDataInMTMarkerCell()
		{
			var allParaOccurrences = m_helper.MakeAnalysesUsedN(5);
			var row0 = m_helper.MakeRow1a();
			var row1 = m_helper.MakeSecondRow();
			int ilastCol = m_logic.AllMyColumns.Length - 1;
			m_helper.MakeWordGroup(row0, ilastCol, allParaOccurrences[0], allParaOccurrences[0]);
			var cellPart1_0 = m_helper.MakeWordGroup(row1, 0, allParaOccurrences[1], allParaOccurrences[2]);
			var cellPart1_1 = m_helper.MakeWordGroup(row1, 1, allParaOccurrences[3], allParaOccurrences[4]);
			var cellPart1_2 = m_helper.MakeMovedTextMarker(row1, 2, cellPart1_0, true);
			var cell = new ChartLocation(row1, 1);
			var nextHvo = cellPart1_2.Hvo + 1;
			EndSetupTask();

			// SUT
			m_logic.MoveWordForward(cell);

			// Verify
			var newCellPart = VerifyCreatedCellPart(nextHvo, "Should create one new WordGroup") as IConstChartWordGroup;
			// Should put new WordGroup after preposed Marker
			VerifyRowContents(1, new IConstituentChartCellPart[] { cellPart1_0, cellPart1_1, cellPart1_2, newCellPart });
			VerifyWordGroup(1, 3, m_logic.AllMyColumns[2], new List<AnalysisOccurrence> { allParaOccurrences[4] });
			VerifyWordGroup(1, 1, m_logic.AllMyColumns[1], new List<AnalysisOccurrence> { allParaOccurrences[3] });
		}
Beispiel #31
0
 /// <summary>
 /// Sets the member variable for the clicked cell's RowColMenuItem.
 /// Call SetupParameterObject() to install it.
 /// </summary>
 /// <param name="row"></param>
 /// <param name="icolSrc"></param>
 void SetClickedCell(IConstChartRow row, int icolSrc)
 {
     m_origCell = new ChartLocation(row, icolSrc);
 }
Beispiel #32
0
		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);
		}
		public void MoveWordForwardPutsMovedTextInMarkerCell()
		{
			var allParaOccurrences = m_helper.MakeAnalysesUsedN(2);
			var row0 = m_helper.MakeRow1a();
			var row1 = m_helper.MakeSecondRow();
			var ilastcol = m_logic.AllMyColumns.Length - 1;
			m_helper.MakeWordGroup(row0, ilastcol, allParaOccurrences[0], allParaOccurrences[0]);
			var cellPart1_0 = m_helper.MakeWordGroup(row1, 0, allParaOccurrences[1], allParaOccurrences[1]);
			var cellPart1_1 = m_helper.MakeMovedTextMarker(row1, 1, cellPart1_0, true);
			var cell = new ChartLocation(row1, 0);
			EndSetupTask();

			// SUT
			m_logic.MoveWordForward(cell);

			// Verify
			VerifyDeletedHvos(new[] { cellPart1_1.Hvo },
				"Should delete the preposed marker; Hvo {0} still exists!");
			VerifyRowContents(1, new[] { cellPart1_0 }); // Should delete marker from row
			VerifyWordGroup(1, 0, m_logic.AllMyColumns[1], new List<AnalysisOccurrence> { allParaOccurrences[1] });
		}
Beispiel #34
0
		public void InsertAndRemoveMarker()
		{
			int[] allParaWfics = MakeAnnotationsUsedN(1);
			CmIndirectAnnotation row0 = MakeRow("1a");
			CmIndirectAnnotation cca0_1 = MakeColumnAnnotation(1, new int[] { allParaWfics[0] }, row0);
			ICmPossibility marker = Cache.LangProject.DiscourseDataOA.ChartMarkersOA.PossibilitiesOS[1].SubPossibilitiesOS[0];
			ChartLocation row0col1 = new ChartLocation(1, row0);

			using (NotifyChangeSpy spy = new NotifyChangeSpy(Cache.MainCacheAccessor))
			{
				m_logic.AddOrRemoveMarker(new RowColPossibilityMenuItem(row0col1, marker.Hvo));
				VerifyInsertMarker(spy, row0, marker);
				spy.AssertHasNotification(row0.Hvo,
					(int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 1, 1, 0);
			}
			// Now test Undo
			using (NotifyChangeSpy undoSpy = new NotifyChangeSpy(Cache.MainCacheAccessor))
			{
				Assert.IsTrue(Cache.CanUndo);
				Cache.Undo();
				VerifyRemovedMarker(allParaWfics);
				// Verify various PropChanged calls.
				undoSpy.AssertHasNotification(row0.Hvo,
					(int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0, 1, 2);
			}

			// And now Redo
			using (NotifyChangeSpy redoSpy = new NotifyChangeSpy(Cache.MainCacheAccessor))
			{
				Assert.IsTrue(Cache.CanRedo);
				Cache.Redo();
				VerifyInsertMarker(redoSpy, row0, marker);
				redoSpy.AssertHasNotification(row0.Hvo,
					(int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0, 2, 1);
			}

			// Now make sure we can delete it again.
			using (NotifyChangeSpy delSpy = new NotifyChangeSpy(Cache.MainCacheAccessor))
			{
				RowColPossibilityMenuItem item = new RowColPossibilityMenuItem(row0col1, marker.Hvo);
				item.Checked = true;
				m_logic.AddOrRemoveMarker(item);
				VerifyRemovedMarker(allParaWfics);
				delSpy.AssertHasNotification(row0.Hvo,
					(int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 1, 0, 1);
			}
			// Now test Undo
			using (NotifyChangeSpy undoSpy2 = new NotifyChangeSpy(Cache.MainCacheAccessor))
			{
				Assert.IsTrue(Cache.CanUndo);
				Cache.Undo();
				VerifyInsertMarker(undoSpy2, row0, marker);
				undoSpy2.AssertHasNotification(row0.Hvo,
					(int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0, 2, 1);
			}

			// And now Redo
			using (NotifyChangeSpy redoSpy2 = new NotifyChangeSpy(Cache.MainCacheAccessor))
			{
				Assert.IsTrue(Cache.CanRedo);
				Cache.Redo();
				VerifyRemovedMarker(allParaWfics);
				// Verify various PropChanged calls.
				redoSpy2.AssertHasNotification(row0.Hvo,
					(int)CmIndirectAnnotation.CmIndirectAnnotationTags.kflidAppliesTo, 0, 1, 2);
			}
		}
Beispiel #35
0
 internal List <ICmIndirectAnnotation> CallCollectEligRows(ChartLocation cell, bool fPrepose)
 {
     return(CollectEligibleRows(cell, fPrepose));
 }
Beispiel #36
0
		/// <summary>
		/// Selects and scrolls to the bookmarked location in the constituent chart. This version
		/// assumes the bookmarked location has been charted, since the location is passed as a parameter.
		/// </summary>
		/// <param name="chartLoc">A ChartLocation object, created by CCLogic.FindChartLocOfWfic().</param>
		/// <param name="fbookmark">true if called for a bookmark, false if called for ChOrph highlighting</param>
		internal void SelectAndScrollToLoc(ChartLocation chartLoc, bool fbookmark)
		{
			Debug.Assert(m_chart != null);
			Debug.Assert(chartLoc != null);
			Debug.Assert(chartLoc.RowAnn != null);

			// The following will select the row of the bookmark
			ICmIndirectAnnotation row = chartLoc.RowAnn;
			IVwSelection sel = MakeRowSelection(row, true);
			if (fbookmark)
				ScrollSelectionIntoView(sel, VwScrollSelOpts.kssoTop);
			else
				ScrollSelectionIntoView(sel, VwScrollSelOpts.kssoNearTop);
			//Update(); ScrollSelectionIntoView() does this, I believe.
		}
Beispiel #37
0
		internal void VerifyMergeCellsEvent(ChartLocation srcCell, ChartLocation dstCell, bool forward)
		{
			//m_events.Add(new object[] { "merge cell contents", srcCell, dstCell, forward });
			object[] event1 = VerifyEventExists("merge cell contents", 3);
			Assert.IsTrue(srcCell.IsSameLocation(event1[1]));
			Assert.IsTrue(dstCell.IsSameLocation(event1[2]));
			Assert.AreEqual(forward, event1[3]);
		}
		public void MoveWordForwardGroupToGroup()
		{
			int[] allParaWfics = m_helper.MakeAnnotationsUsedN(3);
			CmIndirectAnnotation row0 = m_helper.MakeFirstRow();
			CmIndirectAnnotation cca0_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[0], allParaWfics[1] }, row0);
			CmIndirectAnnotation cca0_2 = m_helper.MakeColumnAnnotation(2, new int[] { allParaWfics[2] }, row0);
			ChartLocation cell = new ChartLocation(1, row0);
			StartCheckingDataAccess();
			m_sdaChecker.ExpectVector(cca0_1.Hvo, kflidAppliesTo, new int[] { allParaWfics[0] },
				"should have moved word out of cell 1");
			m_sdaChecker.ExpectVector(cca0_2.Hvo, kflidAppliesTo, new int[] { allParaWfics[1], allParaWfics[2] },
				"should have moved word into cell 2");
			m_logic.MoveWordForward(cell);
			m_sdaChecker.VerifyExpectedChanges();
			(Cache.ActionHandlerAccessor as MockActionHandler).VerifyUndoRedoText(
				ConstituentChartLogic.FTO_UndoMoveWord, ConstituentChartLogic.FTO_RedoMoveWord, "should be undo move word");
		}
Beispiel #39
0
		protected override void MergeCellContents(ChartLocation srcCell, ChartLocation dstCell,	bool forward)
		{
			if (m_fRecordMergeCellContents)
				m_events.Add(new object[] { "merge cell contents", srcCell, dstCell, forward });
			else
				base.MergeCellContents(srcCell, dstCell, forward);
		}
		public void MoveWordForwardSingleWordToEmpty()
		{
			int[] allParaWfics = m_helper.MakeAnnotationsUsedN(3);
			CmIndirectAnnotation row0 = m_helper.MakeFirstRow();
			CmIndirectAnnotation cca0_1 = m_helper.MakeColumnAnnotation(1, new int[] { allParaWfics[0] }, row0);
			ChartLocation cell = new ChartLocation(1, row0);
			StartCheckingDataAccess();
			m_sdaChecker.ExpectAtomic(cca0_1.Hvo, kflidInstanceOf, m_logic.AllMyColumns[2],
				"should have moved word from col 1 to 2");
			m_logic.MoveWordForward(cell);
			m_sdaChecker.VerifyExpectedChanges();
			(Cache.ActionHandlerAccessor as MockActionHandler).VerifyUndoRedoText(
				ConstituentChartLogic.FTO_UndoMoveWord, ConstituentChartLogic.FTO_RedoMoveWord, "should be undo move word");
		}
Beispiel #41
0
 internal bool CallIsMarkedAsMovedFrom(ChartLocation actualCell, int icolMovedFrom)
 {
     return(IsMarkedAsMovedFrom(actualCell, icolMovedFrom));
 }
		public void MoveWordForwardSingleWordToGroupInNextRow()
		{
			int[] allParaWfics = m_helper.MakeAnnotationsUsedN(2);
			CmIndirectAnnotation row0 = m_helper.MakeRow1a();
			CmIndirectAnnotation row1 = m_helper.MakeSecondRow();
			int ccols = m_logic.AllMyColumns.Length;
			CmIndirectAnnotation cca0_last = m_helper.MakeColumnAnnotation(ccols - 1, new int[] { allParaWfics[0] }, row0);
			CmIndirectAnnotation cca1_0 = m_helper.MakeColumnAnnotation(0, new int[] { allParaWfics[1] }, row1);
			ChartLocation cell = new ChartLocation(ccols - 1, row0);
			StartCheckingDataAccess();
			m_sdaChecker.ExpectVector(cca1_0.Hvo, kflidAppliesTo, new int[] { allParaWfics[0], allParaWfics[1] },
				"should have moved word to start of row1");
			m_sdaChecker.ExpectDeleteObjects(new int[] {row0.Hvo, cca0_last.Hvo } );
			m_sdaChecker.ExpectVector(m_chart.Hvo, kflidRows, new int[] { row1.Hvo },
				"should have deleted row0");
			// With smarter row numbering update row1's comment too! (1b ->1)
			m_sdaChecker.ExpectStringAlt(row1.Hvo, kflidComment, Cache.DefaultAnalWs, Cache.MakeAnalysisTss("1"),
				"should have modified row number");
			m_logic.MoveWordForward(cell);
			m_sdaChecker.VerifyExpectedChanges();
			(Cache.ActionHandlerAccessor as MockActionHandler).VerifyUndoRedoText(
				ConstituentChartLogic.FTO_UndoMoveWord, ConstituentChartLogic.FTO_RedoMoveWord, "should be undo move word");
		}
Beispiel #43
0
		internal void CallRemoveDepClause(ChartLocation srcCell)
		{
			RemoveDepClause(srcCell);
		}
Beispiel #44
0
 internal List <IConstChartRow> CallCollectEligRows(ChartLocation cell, bool fPrepose)
 {
     return(CollectEligibleRows(cell, fPrepose));
 }
Beispiel #45
0
 /// <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 void MoveWordForwardGroupToGroup()
		{
			var allParaOccurrences = m_helper.MakeAnalysesUsedN(3);
			var row0 = m_helper.MakeFirstRow();
			m_helper.MakeWordGroup(row0, 1, allParaOccurrences[0], allParaOccurrences[1]);
			m_helper.MakeWordGroup(row0, 2, allParaOccurrences[2], allParaOccurrences[2]);
			var cell = new ChartLocation(row0, 1);
			EndSetupTask(); // SUT has its own UOW

			// SUT
			m_logic.MoveWordForward(cell);

			// Verify
			// Should have moved word out of cell 1
			VerifyWordGroup(0, 0, m_allColumns[1], new List<AnalysisOccurrence> { allParaOccurrences[0] });
			// Should have moved word into cell 2
			VerifyWordGroup(0, 1, m_allColumns[2], new List<AnalysisOccurrence> { allParaOccurrences[1], allParaOccurrences[2] });
		}
Beispiel #47
0
 internal int CallFindIndexOfCellPartInLaterColumn(ChartLocation targetCell)
 {
     return(FindIndexOfCellPartInLaterColumn(targetCell));
 }
		public void MoveWordForwardSingleWordToEmpty()
		{
			var allParaOccurrences = m_helper.MakeAnalysesUsedN(3);
			var row0 = m_helper.MakeFirstRow();
			m_helper.MakeWordGroup(row0, 1, allParaOccurrences[0], allParaOccurrences[0]);
			var cell = new ChartLocation(row0, 1);
			EndSetupTask(); // SUT has its own UOW

			// SUT
			m_logic.MoveWordForward(cell);

			// Verify
			// should have moved word from col 1 to 2
			VerifyWordGroup(0, 0, m_allColumns[2], new List<AnalysisOccurrence> { allParaOccurrences[0] });
		}
Beispiel #49
0
		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 void MoveWordForwardSingleWordToGroupInNextRow()
		{
			var allParaOccurrences = m_helper.MakeAnalysesUsedN(2);
			var row0 = m_helper.MakeRow1a();
			var row1 = m_helper.MakeSecondRow();
			var icolLast = m_logic.AllMyColumns.Length - 1;
			var cellPart0_last = m_helper.MakeWordGroup(row0, icolLast, allParaOccurrences[0], allParaOccurrences[0]);
			m_helper.MakeWordGroup(row1, 0, allParaOccurrences[1], allParaOccurrences[1]);
			var cell = new ChartLocation(row0, icolLast);
			EndSetupTask(); // SUT has its own UOW

			// SUT
			m_logic.MoveWordForward(cell);

			// Verify
			VerifyDeletedHvos(new[] { row0.Hvo, cellPart0_last.Hvo },
				"Should delete empty row0 and redundant WordGroup; Hvo {0} still exists!");
			VerifyChartRows(m_chart, new[] { row1 }); // Should have deleted the empty row0 from the chart
			// With smarter row numbering update row1's comment too! (1b ->1)
			VerifyRowNumber("1", row1, "Should have modified row number");
			// should have moved word from last col to first of next (& only remaining) row
			VerifyWordGroup(0, 0, m_allColumns[0], new List<AnalysisOccurrence> { allParaOccurrences[0], allParaOccurrences[1] });
		}
		/// <summary>
		/// Sets the member variable for the clicked cell's RowColMenuItem.
		/// Call SetupParameterObject() to install it.
		/// </summary>
		/// <param name="row"></param>
		/// <param name="icolSrc"></param>
		void SetClickedCell(IConstChartRow row, int icolSrc)
		{
			m_origCell = new ChartLocation(row, icolSrc);
		}