This class exists to be the argument to AddObjectSideEffects, and possibly eventually to events which deal with adding objects to sequences and collections. It provides the information we have so far found to be useful, but can readily be enhanced with more. We are considering the possibility of merging this class with one of the FdoStateChange classes so that they can share all the information required to Undo the change, and thus everything required to inform anyone of what changed.
Esempio n. 1
0
		protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e)
		{
			if (e.Flid == RnResearchNbkTags.kflidRecords)
				UpdateAllRecords();

			base.AddObjectSideEffectsInternal(e);
		}
Esempio n. 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This version overrides the CmObject version. Handles various Scripture side effects
		/// and TagsOC modifications.
		/// </summary>
		/// <param name="e"></param>
		/// ------------------------------------------------------------------------------------
		protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e)
		{
			// Prevent accidentally adding a plain StTxtPara to a Scripture text...
			// the ScrTxtPara subclass should always be used.
			// But watch out for the case (FWR-3477) where paragraph is owned by a CmPossibility first!
			if (e.Flid == StTextTags.kflidParagraphs
				&& (OwnerOfClass<IScripture>() != null && !(Owner is ICmPossibility))
				&& !(e.ObjectAdded is ScrTxtPara))
				throw new ArgumentException("Can not add object of type " + e.ObjectAdded.GetType() +
					" to this StText");

			base.AddObjectSideEffectsInternal(e);

			//if (e.Flid == StTextTags.kflidTags)
			//    TextTagCollectionChanges(true, e.ObjectAdded);

			if (e.Flid == StTextTags.kflidParagraphs)
			{
				if (e.ObjectAdded is IScrTxtPara)
				{
					IScrSection section = OwnerOfClass<IScrSection>();
					if (section != null)
						((ScrSection)section).AdjustReferences();
				}

				if (e.Index == ParagraphsOS.Count - 1 && e.Index > 0)
				{
					int flid = Services.GetInstance<Virtuals>().StParaIsFinalParaInText;
					Services.GetInstance<IUnitOfWorkService>().RegisterVirtualAsModified(
						ParagraphsOS[e.Index - 1], flid, true, false);
				}
			}
		}
Esempio n. 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Overridden to allow special handling to prevent moving Scripture paragraphs to a
		/// different book.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void ValidateAddObjectInternal(AddObjectEventArgs e)
		{
			if (e.Flid == StTextTags.kflidParagraphs &&
				e.ObjectAdded.Hvo != (int)SpecialHVOValues.kHvoUninitializedObject)
			{
				IScrBook originalOwningBook = e.ObjectAdded.OwnerOfClass<IScrBook>();
				if (originalOwningBook != null)
				{
					// this StText is the one that is to be the new owner.
					IScrBook newOwningBook = OwnerOfClass<IScrBook>();
					if (newOwningBook != originalOwningBook)
						throw new InvalidOperationException("Scripture pargraphs cannot be moved between books.");
				}
			}
			base.ValidateAddObjectInternal(e);
		}
		protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e)
		{
			switch (e.Flid)
			{
				case MoInflAffMsaTags.kflidSlots:
					var target = ((IMoInflAffixSlot) e.ObjectAdded);
					var flid = m_cache.MetaDataCache.GetFieldId2(MoInflAffixSlotTags.kClassId, "Affixes", false);

					var newGuids = (from msa in target.Affixes select msa.Guid).ToArray();

					m_cache.ServiceLocator.GetInstance<IUnitOfWorkService>().RegisterVirtualAsModified(target, flid,
						new Guid[0], newGuids);
					break;
				default:
					base.AddObjectSideEffectsInternal(e);
					break;
			}
		}
Esempio n. 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Need this version, because the ICmObjectInternal.ValidateAddObject version
		/// can't be virtual, and we want subclasses to be able to override the method.
		/// </summary>
		/// <exception cref="InvalidOperationException">The addition is not valid</exception>
		/// ------------------------------------------------------------------------------------
		protected override void ValidateAddObjectInternal(AddObjectEventArgs e)
		{
			base.ValidateAddObjectInternal(e);

			if (e.Flid == StTxtParaTags.kflidTranslations)
			{
				if (Cache.FullyInitializedAndReadyToRock && TranslationsOC.Count > 0)
					throw new InvalidOperationException("Can not have more than one CmTranslation for a paragraph (kind of makes you wonder why we have a collection)");

				ICmTranslation trans = (ICmTranslation)e.ObjectAdded;
				if (trans.TypeRA != null && trans.TypeRA.Guid != LangProjectTags.kguidTranBackTranslation)
					throw new ArgumentException("Back translations are the only type of translation allowed for paragraphs");
			}
		}
Esempio n. 6
0
		protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e)
		{
			if (e.Flid == RnGenericRecTags.kflidSubRecords)
			{
				var notebook = OwnerOfClass<RnResearchNbk>();
				notebook.UpdateAllRecords();

				int flid = m_cache.MetaDataCache.GetFieldId2(RnGenericRecTags.kClassId, "IndexInOwnerTSS", false);
				ITsString dummy = m_cache.TsStrFactory.MakeString("", m_cache.DefaultAnalWs);
				RegisterAllSubrecordIndexTSSChanged(this.SubRecordsOS, flid, dummy);
				NoteSubrecordOfChanges(this, e.Index);
			}
			base.AddObjectSideEffectsInternal(e);
		}
Esempio n. 7
0
		protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e)
		{
			switch (e.Flid)
			{
				case TextTags.kflidGenres:
					if (ContentsOA != null)
						InternalServices.UnitOfWorkService.RegisterVirtualAsModified(ContentsOA, "GenreCategories", GenresRC.Cast<ICmObject>());
					return; // still do the default thing, base class has this property too.
			}
			base.AddObjectSideEffectsInternal(e);
		}
Esempio n. 8
0
		protected override void AddObjectSideEffectsInternal(AddObjectEventArgs e)
		{
			switch(e.Flid)
			{
				case WfiAnalysisTags.kflidEvaluations:
					AdjustApprovalLists((IWfiWordform)Owner);
					return;
			}
			base.AddObjectSideEffectsInternal(e);
		}
Esempio n. 9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Validation done before adding an object to some vector flid.
		/// </summary>
		/// <exception cref="InvalidOperationException">The addition is not valid</exception>
		/// ------------------------------------------------------------------------------------
		protected override void ValidateAddObjectInternal(AddObjectEventArgs e)
		{
			if (e.Flid == ScrFootnoteTags.kflidParagraphs && ParagraphsOS.Count >= s_maxAllowedParagraphs)
				throw new InvalidOperationException("Scripture footnotes are limited to " + s_maxAllowedParagraphs + " paragraph(s).");
			base.ValidateAddObjectInternal(e);
		}