This class manages various information about lists of writing systems. Review JohnT: would these be more naturally methods of LangProject? If not, where should this class go? Note that much of the functionality ought to be used by MultiStringSlice, and probably by other classes that are nothing to do with IText. I'm thinking it might belong in the same DLL as LangProject.
Inheritance: IFWDisposable
 /// <summary>
 /// Add to the vwenv the label(s) for a gloss line.
 /// If multiple glosses are wanted, it generates a set of labels
 /// </summary>
 public void AddGlossLabels(IVwEnv vwenv, ITsStrFactory tsf, int color, string baseLabel,
                            FdoCache cache, WsListManager wsList)
 {
     if (wsList != null && wsList.AnalysisWsLabels.Length > 1)
     {
         ITsString tssBase = MakeUiElementString(baseLabel, cache.DefaultUserWs, null);
         ITsString space   = tsf.MakeString(" ", cache.DefaultUserWs);
         foreach (ITsString tssLabel in wsList.AnalysisWsLabels)
         {
             SetColor(vwenv, color);
             vwenv.OpenParagraph();
             vwenv.AddString(tssBase);
             vwenv.AddString(space);
             vwenv.AddString(tssLabel);
             vwenv.CloseParagraph();
         }
     }
     else
     {
         AddColoredString(vwenv, color, tsf, cache.DefaultAnalWs, baseLabel);
     }
 }
示例#2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="InterlinVc"/> class.
		/// </summary>
		/// <remarks>We use the default analysis writing system as the default, even though
		/// this view displays data in multiple writing systems. It's pretty arbitrary in this
		/// case, but we need a valid WS because if we get an ORC, we have to create a Ts String
		/// using some writing system.</remarks>
		/// <param name="cache">The cache.</param>
		/// ------------------------------------------------------------------------------------
		public InterlinVc(FdoCache cache) : base(cache.DefaultAnalWs)
		{
			Cache = cache;
			m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
			m_segRepository = m_cache.ServiceLocator.GetInstance<ISegmentRepository>();
			m_coRepository = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>();
			m_wmbRepository = m_cache.ServiceLocator.GetInstance<IWfiMorphBundleRepository>();
			m_analRepository = m_cache.ServiceLocator.GetInstance<IWfiAnalysisRepository>();
			StTxtParaRepository = m_cache.ServiceLocator.GetInstance<IStTxtParaRepository>();
			m_wsAnalysis = cache.DefaultAnalWs;
			m_wsUi = cache.LanguageWritingSystemFactoryAccessor.UserWs;
			Decorator = new InterlinViewDataCache(m_cache);
			PreferredVernWs = cache.DefaultVernWs;
			m_selfFlid = m_cache.MetaDataCacheAccessor.GetFieldId2(CmObjectTags.kClassId, "Self", false);
			m_tssMissingGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
			m_tssMissingGlossPrepend = m_tsf.MakeString(ITextStrings.ksStars + MorphServices.kDefaultSeparatorLexEntryInflTypeGlossAffix, m_wsAnalysis);
			m_tssMissingGlossAppend = m_tsf.MakeString(MorphServices.kDefaultSeparatorLexEntryInflTypeGlossAffix + ITextStrings.ksStars, m_wsAnalysis);
			m_tssMissingSense = m_tssMissingGloss;
			m_tssMissingMsa = m_tssMissingGloss;
			m_tssMissingAnalysisPos = m_tssMissingGloss;
			m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis);
			m_WsList = new WsListManager(m_cache);
			m_tssEmptyPara = m_tsf.MakeString(ITextStrings.ksEmptyPara, m_wsAnalysis);
			m_tssSpace = m_tsf.MakeString(" ", m_wsAnalysis);
			m_msaVc = new MoMorphSynAnalysisUi.MsaVc(m_cache);
			m_vernWss = WritingSystemServices.GetAllWritingSystems(m_cache, "all vernacular",
				null, 0, 0);
			// This usually gets overridden, but ensures default behavior if not.
			m_lineChoices = InterlinLineChoices.DefaultChoices(m_cache.LangProject,
				WritingSystemServices.kwsVernInParagraph, WritingSystemServices.kwsAnal);
			// This used to be a constant but was made variables with dummy virtual handlers so that
			// ClearInfoAbout can clear them out.
			// load guesses
			ktagSegmentForms = SegmentTags.kflidAnalyses;
			GetSegmentLevelTags(cache);
			LangProjectHvo = m_cache.LangProject.Hvo;
		}
示例#3
0
		/// <summary/>
		protected virtual void Dispose(bool fDisposing)
		{
			System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().ToString() + " *******");
			if (fDisposing && !IsDisposed)
			{
				// dispose managed and unmanaged objects
				// Dispose managed resources here.
				if (m_WsList != null)
					m_WsList.Dispose();

				TsStringUtils.ReassignTss(ref m_tssMissingAnalysis, null);
				TsStringUtils.ReassignTss(ref m_tssMissingGloss, null);
				TsStringUtils.ReassignTss(ref m_tssEmptyAnalysis, null);
				TsStringUtils.ReassignTss(ref m_tssEmptyVern, null);
				TsStringUtils.ReassignTss(ref m_tssEmptyPara, null);
				TsStringUtils.ReassignTss(ref m_tssSpace, null);
				TsStringUtils.ReassignTss(ref m_tssCommaSpace, null);

				if (m_tsf != null)
					Marshal.ReleaseComObject(m_tsf);
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_msaVc = null;
			m_cache = null;

			m_tssMissingMorph = null; // Same as m_tssMissingAnalysis.
			m_tssMissingSense = null; // Same as m_tssMissingGloss.
			m_tssMissingMsa = null; // Same as m_tssMissingGloss.
			m_tssMissingAnalysisPos = null; // Same as m_tssMissingGloss.
			m_tssMissingEntry = null; // Same as m_tssEmptyAnalysis.
			m_tsf = null;
			m_WsList = null;

			IsDisposed = true;
		}
			/// <summary>
			/// Add to the vwenv the label(s) for a gloss line.
			/// If multiple glosses are wanted, it generates a set of labels
			/// </summary>
			public void AddGlossLabels(IVwEnv vwenv, ITsStrFactory tsf, int color, string baseLabel,
				FdoCache cache, WsListManager wsList)
			{
				if (wsList != null && wsList.AnalysisWsLabels.Length > 1)
				{
					ITsString tssBase = MakeUiElementString(baseLabel, cache.DefaultUserWs, null);
					ITsString space = tsf.MakeString(" ", cache.DefaultUserWs);
					foreach (ITsString tssLabel in wsList.AnalysisWsLabels)
					{
						SetColor(vwenv, color);
						vwenv.OpenParagraph();
						vwenv.AddString(tssBase);
						vwenv.AddString(space);
						vwenv.AddString(tssLabel);
						vwenv.CloseParagraph();
					}
				}
				else
				{
					AddColoredString(vwenv, color, tsf, cache.DefaultAnalWs, baseLabel);
				}
			}
示例#5
0
		// Is hvoAnn, currently analyzed as hvoAnalysis, fully analyzed?
		// This means:
		//  -- it isn't a default (property InterlinVc.m_vc.ktagTwficDefault isn't cached)
		//  -- It's a WfiGloss, with non-empty form.
		//  -- Owner is a WfiAnalysis with non-empty Category.
		//  -- Owner has at least one WfiMorphBundle.
		//  -- For each WfiMorphBundle, Form, Msa, and Sense are all filled in.
		// Alternatively, if hvoAnalysis is zero, the annotation is punctuation, which we don't analyze further;
		// so return true to indicate that it needs no further attention.
		internal bool FullyAnalyzed(FdoCache fdoCache, WsListManager listman, int hvoAnn, int hvoAnalysis)
		{
			int ktagTwficDefault = StTxtPara.TwficDefaultFlid(fdoCache);
			if (hvoAnalysis == 0)
				return true; // punctuation, treat as fully analyzed.
			ISilDataAccess sda = fdoCache.MainCacheAccessor;
			// Check for default. If the analysis we're showing is a default it needs at least confirmation.
			if (sda.get_IsPropInCache(hvoAnn, ktagTwficDefault, (int)CellarModuleDefns.kcptReferenceAtom, 0)
				&& sda.get_ObjectProp(hvoAnn, ktagTwficDefault) != 0)
				return false;

			int analysisClass = fdoCache.GetClassOfObject(hvoAnalysis);
			if (analysisClass != (int)WfiGloss.kclsidWfiGloss && analysisClass != (int)WfiAnalysis.kclsidWfiAnalysis)
				return false; // Has to BE an analysis...unless pathologically everything is off? Too bad if so...
			int hvoWfiAnalysis = fdoCache.GetOwnerOfObject(hvoAnalysis);
			int hvoWordform;
			if (analysisClass == (int)WfiAnalysis.kclsidWfiAnalysis)
			{
				hvoWordform = hvoWfiAnalysis;
				hvoWfiAnalysis = hvoAnalysis;
			}
			else
			{
				hvoWordform = fdoCache.GetOwnerOfObject(hvoWfiAnalysis);
			}

			foreach (InterlinLineSpec spec in m_vc.LineChoices)
			{
				// see if the information required for this linespec is present.
				switch (spec.Flid)
				{
					case InterlinLineChoices.kflidWord:
						int ws = m_vc.GetRealWs(hvoWordform, spec);
						if (sda.get_MultiStringAlt(hvoWordform, (int)WfiWordform.WfiWordformTags.kflidForm, ws).Length == 0)
							return false;
						break;
					case InterlinLineChoices.kflidLexEntries:
						if (!CheckPropSetForAllMorphs(sda, hvoWfiAnalysis, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph))
							return false;
						break;
					case InterlinLineChoices.kflidMorphemes:
						if (!CheckPropSetForAllMorphs(sda, hvoWfiAnalysis, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph))
							return false;
						break;
					case InterlinLineChoices.kflidLexGloss:
						if (!CheckPropSetForAllMorphs(sda, hvoWfiAnalysis, (int)WfiMorphBundle.WfiMorphBundleTags.kflidSense))
							return false;
						break;
					case InterlinLineChoices.kflidLexPos:
						if (!CheckPropSetForAllMorphs(sda, hvoWfiAnalysis, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa))
							return false;
						break;
					case InterlinLineChoices.kflidWordGloss:
						// If it isn't a WfiGloss the user needs a chance to supply a word gloss.
						if (analysisClass != WfiGloss.kclsidWfiGloss)
							return false;
						// If it is empty for the (possibly magic) ws specified here, it needs filling in.
						int ws1 = m_vc.GetRealWs(hvoAnalysis, spec);
						if (sda.get_MultiStringAlt(hvoAnalysis, (int)WfiGloss.WfiGlossTags.kflidForm, ws1).Length == 0)
							return false;
						break;
					case InterlinLineChoices.kflidWordPos:
						if (sda.get_ObjectProp(hvoWfiAnalysis, (int)WfiAnalysis.WfiAnalysisTags.kflidCategory) == 0)
							return false;
						break;
					case InterlinLineChoices.kflidFreeTrans:
					case InterlinLineChoices.kflidLitTrans:
					case InterlinLineChoices.kflidNote:
					default:
						// unrecognized or non-word-level annotation, nothing required.
						break;
				}
			}

			return true; // If we can't find anything to complain about, it's fully analyzed.
		}
示例#6
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
				if (m_WsList != null)
					m_WsList.Dispose();
				if (m_msaVc != null)
					m_msaVc.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_msaVc = null;
			m_cache = null;

			m_tssMissingMorph = null; // Same as m_tssMissingAnalysis.
			StringUtils.ReassignTss(ref m_tssMissingAnalysis, null);

			m_tssMissingSense = null; // Same as m_tssMissingGloss.
			m_tssMissingMsa = null; // Same as m_tssMissingGloss.
			m_tssMissingAnalysisPos = null; // Same as m_tssMissingGloss.
			StringUtils.ReassignTss(ref m_tssMissingGloss, null);

			m_tssMissingEntry = null; // Same as m_tssEmptyAnalysis.
			StringUtils.ReassignTss(ref m_tssEmptyAnalysis, null);
			StringUtils.ReassignTss(ref m_tssEmptyVern, null);
			StringUtils.ReassignTss(ref m_tssEmptyPara, null);
			StringUtils.ReassignTss(ref m_tssSpace, null);

			Marshal.ReleaseComObject(m_tsf);
			m_tsf = null;

			StringUtils.ReassignTss(ref m_tssCommaSpace, null);
			m_WsList = null;

			base.Dispose(disposing);
		}
示例#7
0
		public InterlinVc(FdoCache cache)
		{
			m_cache = cache;
			m_wsAnalysis = cache.LangProject.DefaultAnalysisWritingSystem;
			m_wsUi = cache.LanguageWritingSystemFactoryAccessor.UserWs;

			PreferredVernWs = cache.LangProject.DefaultVernacularWritingSystem;

			m_tssMissingGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis);
			m_tssMissingSense = m_tssMissingGloss;
			m_tssMissingMsa = m_tssMissingGloss;
			m_tssMissingAnalysisPos = m_tssMissingGloss;
			m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis);
			m_WsList = new WsListManager(m_cache);
			m_tssEmptyPara = m_tsf.MakeString(ITextStrings.ksEmptyPara, m_wsAnalysis);
			m_tssSpace = m_tsf.MakeString(" ", m_wsAnalysis);
			m_flidStringValue = CmBaseAnnotation.StringValuePropId(m_cache);
			m_msaVc = new MoMorphSynAnalysisUi.MsaVc(m_cache);
			m_vernWss = LangProject.GetAllWritingSystems("all vernacular", m_cache, null, 0, 0);

			// This usually gets overridden, but ensures default behavior if not.
			m_lineChoices = InterlinLineChoices.DefaultChoices(0, m_cache.DefaultAnalWs, m_cache.LangProject);
			// These two used to be constants but were made variables with dummy virtual handlers so that
			// ClearInfoAbout can clear them out.
			ktagTwficDefault = TwficDefaultTag(m_cache);
			ktagSegmentForms = SegmentFormsTag(m_cache);
			tagRealForm = TwficRealFormTag(m_cache);
			GetSegmentLevelTags(cache);
		}
示例#8
0
		public ParaDataLoader(FdoCache cache)
		{
			m_cache = cache;
			ktagParaSegments = StTxtPara.SegmentsFlid(m_cache);
			ktagSegmentForms = InterlinVc.SegmentFormsTag(m_cache);
			ktagTwficDefault = InterlinVc.TwficDefaultTag(m_cache);
			ktagMatchingLowercaseForm = InterlinVc.MatchingLowercaseWordForm(m_cache);
			m_WsList = new WsListManager(m_cache);
			m_cda = m_cache.MainCacheAccessor as IVwCacheDa;
		}