Inheritance: SIL.FieldWorks.IText.InterlinVc
		public MaxStringWidthForChartColumn(ConstChartVc vc, IVwStylesheet stylesheet, ISilDataAccess sda, int hvoRoot,
			System.Drawing.Graphics graphics, int icolumn)
			: base(stylesheet, sda, hvoRoot, graphics, icolumn)
		{
			m_vc = vc;
			m_cLines = m_vc.LineChoices.Count;
			m_paraWidths = new int[m_cLines];
		}
Exemplo n.º 2
0
		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.

			}

		}
Exemplo n.º 3
0
		public void Export()
		{
			using (var stream = new MemoryStream())
			{
				//Set up some cells.
				var allParaOccurrences = m_helper.MakeAnalysesUsedN(6);

				// Make last analysis point to WfiWordform instead of WfiGloss
				var lastOccurrence = allParaOccurrences[5];
				var wordform = (lastOccurrence.Analysis as IWfiGloss).Wordform;
				lastOccurrence.Segment.AnalysesRS.Replace(1, 0, new List<ICmObject> { wordform });
				// This block makes the first row, puts WordGroups in cells 1 and 2, and list refs in cells 1 and 2
				var row0 = m_helper.MakeFirstRow();
				var movedItem = allParaOccurrences[1];
				var cellPart0_1 = m_helper.MakeWordGroup(row0, 1, allParaOccurrences[0], allParaOccurrences[0]);
				var marker = m_helper.GetAMarker();
				var cellPart0_1b = m_helper.MakeChartMarker(row0, 1, marker);
				var cellPart0_2 = m_helper.MakeWordGroup(row0, 2, movedItem, movedItem);
				var marker2 = m_helper.GetAnotherMarker();
				var cellPart0_2b = m_helper.MakeChartMarker(row0, 2, marker2);
				var cellPart0_2c = m_helper.MakeChartMarker(row0, 2, marker);
				var cellPart0_3 = m_helper.MakeWordGroup(row0, 3, lastOccurrence, lastOccurrence);

				// Now another row, and cell 4 on the first has a ref to it. The new row has a WordGroup with two
				// wordforms in cell 1. The cell is two columns wide, being merged with the previous cell.
				var row1 = m_helper.MakeSecondRow();
				m_helper.MakeDependentClauseMarker(row0, 4, new[] { row1 }, ClauseTypes.Song);
				var cellPart1_1 = m_helper.MakeWordGroup(row1, 1, allParaOccurrences[2], allParaOccurrences[3]);
				cellPart1_1.MergesBefore = true;

				// Let's have some notes on row 0.
				//var notesText = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
				row0.Notes = Cache.TsStrFactory.MakeString("This is a test note", Cache.DefaultAnalWs);
				//var notesPara = Cache.ServiceLocator.GetInstance<IStTxtParaFactory>().Create();
				//notesText.ParagraphsOS.Add(notesPara);
				//notesPara.Contents = ;

				// And some moved text in row 1
				var cellPart1_2 = m_helper.MakeWordGroup(row1, 2, allParaOccurrences[4], allParaOccurrences[4]);
				m_helper.MakeMovedTextMarker(row1, 3, cellPart1_2, true);

				// We need four rows to properly test the variations on endPara/endSent
				var row2 = m_helper.MakeRow(m_chart, "2");
				row2.EndSentence = true;
				var row3 = m_helper.MakeRow(m_chart, "3");
				row3.EndSentence = true;
				row3.EndParagraph = true;
				m_helper.MakeRow(m_chart, "4");

				using (var writer = new XmlTextWriter(stream, Encoding.UTF8))
				{
					using (var vc = new ConstChartVc(m_chartBody))
					{
						vc.LineChoices = m_chartBody.LineChoices;
						using (var exporter = new DiscourseExporter(Cache, writer, m_chart.Hvo, vc, Cache.DefaultAnalWs))
						{
							writer.WriteStartDocument();
							writer.WriteStartElement("document");
							exporter.ExportDisplay();
							writer.WriteEndElement();
							writer.WriteEndDocument();
							writer.Flush();
							// Close makes it unuseable
							stream.Position = 0;
							using (var reader = new StreamReader(stream, Encoding.UTF8))
							{
								var result = reader.ReadToEnd();
								var doc = new XmlDocument();
								doc.LoadXml(result);
								var docNode = doc.DocumentElement;
								Assert.AreEqual("document", docNode.Name);
								var chartNode = VerifyNode("chart", docNode, 0, "chart", 7, 0);
								VerifyTitleRow(chartNode);
								VerifyTitle2Row(chartNode);
								VerifyFirstDataRow(chartNode);
								VerifySecondDataRow(chartNode);
								var thirdRow = VerifyNode("row", chartNode, 4, "row", 8, 3);
								AssertAttr(thirdRow, "endSent", "true");
								var fourthRow = VerifyNode("row", chartNode, 5, "row", 8, 3);
								AssertAttr(fourthRow, "endPara", "true");

							var langNode = VerifyNode("languages", docNode, 1, "languages", 2, 0);
								var 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.
							}
						}
					}
				}
			}
		}
Exemplo n.º 4
0
		public override void MakeRoot()
		{
			CheckDisposed();

			m_rootb = VwRootBoxClass.Create();
			m_rootb.SetSite(this);

			m_vc = new ConstChartVc(this);
			m_vc.LineChoices = m_lineChoices;
			// may be needed..normally happens when the VC displays a top-level paragraph.
			//SetupRealVernWsForDisplay(m_cache.LangProject.ActualWs(LangProject.kwsVernInParagraph,
			//    hvo, (int)StText.StTextTags.kflidParagraphs));

			m_rootb.DataAccess = Cache.MainCacheAccessor;
			m_rootb.SetRootObject(m_hvoChart, m_vc, ConstChartVc.kfragChart, this.StyleSheet);

			base.MakeRoot();
			//m_rootb.Activate(VwSelectionState.vssOutOfFocus); // Makes selection visible even before ever got focus.
		}
Exemplo n.º 5
0
		/// <summary>
		/// Make one.
		/// </summary>
		/// <param name="baseObj"></param>
		/// <param name="cache"></param>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		public MakeCellsMethod(ConstChartVc baseObj, FdoCache cache, IVwEnv vwenv, int hvo)
		{
			m_this = baseObj;
			m_cache = cache;
			m_vwenv = vwenv;
			m_hvoRow = hvo;
			m_chart = baseObj.m_chart;
		}
Exemplo n.º 6
0
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (m_cellContextMenu != null)
					m_cellContextMenu.Dispose();
				if (m_vc != null)
					m_vc.Dispose();
				if (m_hoverButton != null)
				{
					if (Controls.Contains(m_hoverButton))
						Controls.Remove(m_hoverButton);
					m_hoverButton.Dispose();
				}
			}
			m_cellContextMenu = null;
			m_vc = null;
			m_hoverButton = null;
			base.Dispose(disposing);
		}
Exemplo n.º 7
0
		/// <summary>
		/// Make one.
		/// </summary>
		/// <param name="baseObj"></param>
		/// <param name="cache"></param>
		/// <param name="vwenv"></param>
		/// <param name="hvo"></param>
		public MakeCellsMethod(ConstChartVc baseObj, FdoCache cache, IVwEnv vwenv, int hvo)
		{
			m_this = baseObj;
			m_cache = cache;
			m_rowRepo = m_cache.ServiceLocator.GetInstance<IConstChartRowRepository>();
			m_partRepo = m_cache.ServiceLocator.GetInstance<IConstituentChartCellPartRepository>();

			// Decorator makes sure that things get put out in the right order if chart is RtL
			m_chart = baseObj.m_chart;
			//var sPopFormatting = m_cache.TsStrFactory.MakeString(Convert.ToString(m_chart.PDF), m_cache.DefaultAnalWs);
			m_vwenv = new ChartRowEnvDecorator(vwenv);

			m_hvoRow = hvo;
			m_row = m_rowRepo.GetObject(m_hvoRow);
		}