private CurrentContext WriteClassStartTag(int hvoItem) { CurrentContext ccOld = m_cc; if (m_cc != CurrentContext.insideLink) { m_cc = CurrentContext.insideObject; } int clid = m_cache.GetClassOfObject(hvoItem); string sClass = m_cache.MetaDataCacheAccessor.GetClassName((uint)clid); IndentLine(); if (m_cc == CurrentContext.insideLink) { sClass = sClass + "Link"; m_writer.WriteLine("<{0} target=\"hvo{1}\">", sClass, hvoItem); } else { if (clid == LexEntry.kclsidLexEntry && m_sFormat == "xhtml") { WriteEntryLetterHeadIfNeeded(hvoItem); } else if (clid == ReversalIndexEntry.kclsidReversalIndexEntry && m_sFormat == "xhtml") { WriteReversalLetterHeadIfNeeded(hvoItem); } m_writer.WriteLine("<{0} id=\"hvo{1}\">", sClass, hvoItem); } m_rgElementTags.Add(sClass); m_rgClassNames.Add(sClass); return(ccOld); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the given object agains the filter criteria /// </summary> /// <param name="hvoObj">ID of object to check against the filter criteria</param> /// <returns> /// <c>true</c> if the object passes the filter criteria; otherwise /// <c>false</c> /// </returns> /// <remarks>currently only handles basic filters (single cell)</remarks> /// ------------------------------------------------------------------------------------ public bool MatchesCriteria(int hvoObj) { int classId = m_cache.GetClassOfObject(hvoObj); if (classId != ScrScriptureNote.kClassId) { return(false); // Not an annotation or not one we will care about } ScrScriptureNote note = new ScrScriptureNote(m_cache, hvoObj); if (note.AnnotationType != NoteType.CheckingError) { return(true); // Annotation is a Translator or Consultant note } if (note.ResolutionOA != null) { foreach (StTxtPara para in note.ResolutionOA.ParagraphsOS) { if (para.Contents.Length > 0) { return(true); } } } return(false); }
public bool OnPromoteReversalindexEntry(object cmd) { //Command command = (Command) cmd; Slice slice = m_dataEntryForm.CurrentSlice; Debug.Assert(slice != null, "No slice was current"); if (slice != null) { FdoCache cache = m_dataEntryForm.Cache; IReversalIndexEntry entry = slice.Object as IReversalIndexEntry; int hvoNewOwner = cache.GetOwnerOfObject(entry.OwnerHVO); switch (cache.GetClassOfObject(hvoNewOwner)) { default: throw new ArgumentException("Illegal class."); case ReversalIndex.kclsidReversalIndex: { IReversalIndex ri = ReversalIndex.CreateFromDBObject(cache, hvoNewOwner); ri.EntriesOC.Add(entry); break; } case ReversalIndexEntry.kclsidReversalIndexEntry: { IReversalIndexEntry rie = ReversalIndexEntry.CreateFromDBObject(cache, hvoNewOwner); rie.SubentriesOC.Add(entry); break; } } // We may need to notify everyone that a virtual property changed. //NotifyVirtualChanged(cache, slice); } return(true); }
public void SetupDeleteMenu(MenuItem mnuDelete) { mnuDelete.MenuItems.Clear(); int hvoDeleteOwner; int flidDelete; int ihvoDelete = -1; // default for atomic Slice slice = m_sliceTreeNode.Slice; bool isAtomic = slice.GetAtomicContext(out hvoDeleteOwner, out flidDelete); if (isAtomic || slice.GetSeqContext(out hvoDeleteOwner, out flidDelete, out ihvoDelete)) { if (ihvoDelete >= 0) { m_hvoDeleteTarget = m_cache.GetVectorItem(hvoDeleteOwner, flidDelete, ihvoDelete); } else { m_hvoDeleteTarget = m_cache.GetObjProperty(hvoDeleteOwner, flidDelete); } int clsid = m_cache.GetClassOfObject(m_hvoDeleteTarget); string targetClassName = m_cache.GetClassName((uint)clsid); string attrName = m_mdc.GetFieldName((uint)flidDelete); MenuItem item = new MenuItem(String.Format(DetailControlsStrings.ksItemFrom, new object[] { targetClassName, attrName }), new EventHandler(this.HandleDeleteMenuItem)); item.Enabled = OkToDelete(hvoDeleteOwner, flidDelete, isAtomic); mnuDelete.MenuItems.Add(item); } mnuDelete.Enabled = mnuDelete.MenuItems.Count > 0; }
public bool OnPromoteReversalSubPOS(object cmd) { Slice slice = m_dataEntryForm.CurrentSlice; Debug.Assert(slice != null, "No slice was current"); if (slice != null) { FdoCache cache = m_dataEntryForm.Cache; ICmPossibility sliceObj = slice.Object as ICmPossibility; int hvoNewOwner = cache.GetOwnerOfObject(sliceObj.OwnerHVO); switch (cache.GetClassOfObject(hvoNewOwner)) { default: throw new ArgumentException("Illegal class."); case PartOfSpeech.kclsidPartOfSpeech: { IPartOfSpeech pos = PartOfSpeech.CreateFromDBObject(cache, hvoNewOwner); pos.SubPossibilitiesOS.Append(sliceObj); break; } case CmPossibilityList.kclsidCmPossibilityList: { ICmPossibilityList posList = CmPossibilityList.CreateFromDBObject(cache, hvoNewOwner); posList.PossibilitiesOS.Append(sliceObj); break; } } } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the writing system for the HVO. This could either be the vernacular or /// analysis writing system. /// </summary> /// <param name="hvo">HVO</param> /// <returns>Writing system</returns> /// ------------------------------------------------------------------------------------ public int GetWritingSystemForHvo(int hvo) { if (m_cache.GetClassOfObject(hvo) == CmTranslation.kClassId) { return(m_btVc.DefaultWs); } else { return(m_RealVc.DefaultWs); } }
private bool IsItemEligible(ISilDataAccess sda, int hvo, Set <int> possiblePOS) { bool fEnable = false; int hvoMsa = sda.get_ObjectProp(hvo, (int)LexSense.LexSenseTags.kflidMorphoSyntaxAnalysis); if (hvoMsa != 0) { int clsid = m_cache.GetClassOfObject(hvoMsa); if (clsid == MoStemMsa.kClassId) { int pos = sda.get_ObjectProp(hvoMsa, (int)MoStemMsa.MoStemMsaTags.kflidPartOfSpeech); if (pos != 0 && possiblePOS.Contains(pos)) { // Only show it as a change if it is different int hvoClass = sda.get_ObjectProp(hvoMsa, (int)MoStemMsa.MoStemMsaTags.kflidInflectionClass); fEnable = hvoClass != m_selectedHvo; } } } return(fEnable); }
private void m_pOSPopupTreeManager_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { // Todo: user selected a part of speech. // Arrange to turn all relevant items blue. // Remember which item was selected so we can later 'doit'. if (e.Node == null) { m_selectedHvo = 0; m_selectedLabel = ""; } else { int hvo = (e.Node as HvoTreeNode).Hvo; int clid = m_cache.GetClassOfObject(hvo); if (m_cache.ClassIsOrInheritsFrom((uint)clid, (uint)FsFeatStruc.kclsidFsFeatStruc)) { m_selectedHvo = hvo; m_selectedLabel = e.Node.Text; } else { m_selectedHvo = 0; m_selectedLabel = ""; m_tree.Text = ""; } } if (ControlActivated != null) { ControlActivated(this, new EventArgs()); } // Tell the parent control that we may have changed the selected item so it can // enable or disable the Apply and Preview buttons based on the selection. if (ValueChanged != null) { ValueChanged(this, new FwObjectSelectionEventArgs(m_selectedHvo)); } }
public bool OnPromoteSense(object cmd) { Command command = (Command)cmd; Slice slice = m_dataEntryForm.CurrentSlice; Debug.Assert(slice != null, "No slice was current"); if (slice != null) { // Save information so that we can call NotifyVirtualChanged after the change // (which disposes the slice). string propName; int clid; Control parent; GetNotifyVirtChgInfo(slice, out propName, out clid, out parent); FdoCache cache = m_dataEntryForm.Cache; int hvoOwner = slice.Object.OwnerHVO; int flid = slice.Object.OwningFlid; int chvo = cache.GetVectorSize(hvoOwner, flid); int ihvo = cache.GetObjIndex(hvoOwner, flid, slice.Object.Hvo); Debug.Assert(ihvo >= 0); if (ihvo >= 0) { int hvoNewOwner = cache.GetOwnerOfObject(hvoOwner); int ihvoOwner = cache.GetObjIndex(hvoNewOwner, (int)LexEntry.LexEntryTags.kflidSenses, hvoOwner); int clidNewOwner = cache.GetClassOfObject(hvoNewOwner); Debug.Assert(clidNewOwner == LexEntry.kClassId || clidNewOwner == LexSense.kClassId); if (clidNewOwner == LexEntry.kClassId) { cache.MoveOwningSequence(hvoOwner, flid, ihvo, ihvo, hvoNewOwner, (int)LexEntry.LexEntryTags.kflidSenses, ihvoOwner + 1); } else if (clidNewOwner == LexSense.kClassId) { cache.MoveOwningSequence(hvoOwner, flid, ihvo, ihvo, hvoNewOwner, (int)LexSense.LexSenseTags.kflidSenses, ihvoOwner + 1); } // We may need to notify everyone that a virtual property changed. if (clid > 0 && parent != null) { NotifyVirtualChanged(cache, propName, clid, parent); } } } return(true); }
protected void CreateStemMsaXmlElement(XmlDocument doc, XmlNode morphNode, IMoStemMsa stemMsa) { XmlNode stemMsaNode = CreateXmlElement(doc, "stemMsa", morphNode); CreatePOSXmlAttribute(doc, stemMsaNode, stemMsa.PartOfSpeechRA, "cat"); IMoInflClass inflClass = stemMsa.InflectionClassRA; if (inflClass == null) { // use default inflection class of the POS or // the first ancestor POS that has a non-zero default inflection class int inflClassHvo = 0; IPartOfSpeech pos = stemMsa.PartOfSpeechRA; while (pos != null && inflClassHvo == 0) { if (pos.DefaultInflectionClassRAHvo != 0) { inflClassHvo = pos.DefaultInflectionClassRAHvo; } else { int clsid = m_cache.GetClassOfObject(pos.OwnerHVO); if (clsid == PartOfSpeech.kClassId) { pos = PartOfSpeech.CreateFromDBObject(m_cache, pos.OwnerHVO); } else { pos = null; } } } if (inflClassHvo != 0) { inflClass = MoInflClass.CreateFromDBObject(m_cache, inflClassHvo); } } CreateInflectionClassXmlAttribute(doc, stemMsaNode, inflClass, "inflClass"); CreateRequiresInflectionXmlAttribute(doc, stemMsa.PartOfSpeechRAHvo, stemMsaNode); CreateFeatureStructureNodes(doc, stemMsaNode, stemMsa.MsFeaturesOA, stemMsa.Hvo); CreateProductivityRestrictionNodes(doc, stemMsaNode, stemMsa.ProdRestrictRC, "productivityRestriction"); CreateFromPOSNodes(doc, stemMsaNode, stemMsa.FromPartsOfSpeechRC, "fromPartsOfSpeech"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Checks the given object agains the filter criteria /// </summary> /// <param name="hvoObj">ID of object to check against the filter criteria</param> /// <returns><c>true</c> if the object passes the filter criteria; otherwise /// <c>false</c></returns> /// ------------------------------------------------------------------------------------ bool IFilter.MatchesCriteria(int hvoObj) { // Back translations don't distinguish between the sections, so return true // if hvoObj is a section if ((m_viewType & TeViewType.BackTranslation) != 0) { return(m_fdoCache.GetClassOfObject(hvoObj) == ScrSection.kClassId); } try { ScrSection section = new ScrSection(m_fdoCache, hvoObj); return(section.IsIntro == m_fIntroDivision); } catch { // The HVO we got isn't for a section! return(false); } }
/// <summary> /// Return the hvo for theCmBaseAnnotation that /// matches the given boundaries in an StTxtPara object. /// If no exact match is found, return the nearest segment (preferably the following word). /// </summary> /// <param name="hvoStTxtPara"></param> /// <param name="ichMin"></param> /// <param name="ichLim"></param> /// <param name="fOnlyTWFIC">true, if restricted to TWFIC</param> /// <param name="fExactMatch"> true if we return an exact match, false otherwise.</param> /// <returns>hvo is 0 if not found.</returns> static internal int FindAnnotationHvoForStTxtPara(FdoCache cache, int hvoStTxtPara, int ichMin, int ichLim, bool fOnlyTWFIC, out bool fExactMatch) { int twficType = CmAnnotationDefn.Twfic(cache).Hvo; int textSegType = CmAnnotationDefn.TextSegment(cache).Hvo; fExactMatch = false; int clsid = cache.GetClassOfObject(hvoStTxtPara); if (clsid != StTxtPara.kClassId) { Debug.Assert(clsid != StTxtPara.kClassId, "hvoStTxtPara should be of class StTxtPara."); return(0); } int kflidParaSegment = InterlinVc.ParaSegmentTag(cache); ISilDataAccess sda = cache.MainCacheAccessor; // first find the closest segment. int[] segments = cache.GetVectorProperty(hvoStTxtPara, kflidParaSegment, true); ICmBaseAnnotation cbaClosestSeg = FindClosestAnnotation(cache, segments, textSegType, ichMin, ichLim, out fExactMatch); if (cbaClosestSeg == null) { return(0); } // if it was an exact match for a segment, return it. if (cbaClosestSeg != null && fExactMatch && !fOnlyTWFIC) { return(cbaClosestSeg.Hvo); } // otherwise, see if we can find a closer wordform int[] segmentForms = cache.GetVectorProperty(cbaClosestSeg.Hvo, InterlinVc.SegmentFormsTag(cache), true); ICmBaseAnnotation cbaClosestWf = FindClosestAnnotation(cache, segmentForms, twficType, ichMin, ichLim, out fExactMatch); if (cbaClosestWf == null) { return(fOnlyTWFIC ? 0 : cbaClosestSeg.Hvo); } return(cbaClosestWf.Hvo); }
public override void Display(IVwEnv vwenv, int hvo, int frag) { CheckDisposed(); switch (frag) { case kfragContext: IPhContextOrVar ctxtOrVar = PhContextOrVar.CreateFromDBObject(m_cache, hvo); bool isOuterIterCtxt = false; // are we inside an iteration context? this is important since we only open a context pile if we are not // in an iteration context, since an iteration context does it for us if (vwenv.EmbeddingLevel > 0) { int outerHvo, outerTag, outerIndex; vwenv.GetOuterObject(vwenv.EmbeddingLevel - 1, out outerHvo, out outerTag, out outerIndex); isOuterIterCtxt = m_cache.GetClassOfObject(outerHvo) == PhIterationContext.kclsidPhIterationContext; } switch (ctxtOrVar.ClassID) { case PhSequenceContext.kclsidPhSequenceContext: if (m_cache.GetVectorSize(hvo, (int)PhSequenceContext.PhSequenceContextTags.kflidMembers) > 0) { vwenv.AddObjVecItems((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragContext); } else { OpenContextPile(vwenv, false); vwenv.Props = m_bracketProps; vwenv.AddProp((int)PhSequenceContext.PhSequenceContextTags.kflidMembers, this, kfragEmpty); CloseContextPile(vwenv, false); } break; case PhSimpleContextNC.kclsidPhSimpleContextNC: IPhSimpleContextNC ncCtxt = ctxtOrVar as IPhSimpleContextNC; if (ncCtxt.FeatureStructureRAHvo != 0 && ncCtxt.FeatureStructureRA.ClassID == PhNCFeatures.kclsidPhNCFeatures) { // Natural class simple context with a feature-based natural class IPhNCFeatures natClass = ncCtxt.FeatureStructureRA as IPhNCFeatures; int numLines = GetNumLines(ncCtxt); if (numLines == 0) { if (!isOuterIterCtxt) { OpenContextPile(vwenv); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseContextPile(vwenv); } } else if (numLines == 1) { if (!isOuterIterCtxt) { OpenContextPile(vwenv); } // use normal brackets for a single line context vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); // special consonant and vowel natural classes only display the abbreviation if (natClass.Abbreviation.AnalysisDefaultWritingSystem == "C" || natClass.Abbreviation.AnalysisDefaultWritingSystem == "V") { vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC); } else { if (natClass.FeaturesOAHvo != 0 && natClass.FeaturesOA.FeatureSpecsOC.Count > 0) { vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC); } else if (ncCtxt.PlusConstrRS.Count > 0) { vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable); } else { vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable); } } vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseContextPile(vwenv); } } else { // multiline context // left bracket pile int maxNumLines = MaxNumLines; vwenv.Props = m_bracketProps; vwenv.set_IntProperty((int)FwTextPropType.ktptMarginLeading, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagLeftNonBoundary, vwenv); vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagLeftNonBoundary, this, kfragLeftBracketExt); } vwenv.AddProp(ktagLeftBoundary, this, kfragLeftBracketLowHook); vwenv.CloseInnerPile(); // feature and variable pile vwenv.set_IntProperty((int)FwTextPropType.ktptAlign, (int)FwTextPropVar.ktpvEnum, (int)FwTextAlign.ktalLeft); vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, vwenv); vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragFeatNC); vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidPlusConstr, this, kfragPlusVariable); vwenv.AddObjVecItems((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidMinusConstr, this, kfragMinusVariable); vwenv.CloseInnerPile(); // right bracket pile vwenv.Props = m_bracketProps; if (!isOuterIterCtxt) { vwenv.set_IntProperty((int)FwTextPropType.ktptMarginTrailing, (int)FwTextPropVar.ktpvMilliPoint, PILE_MARGIN); } vwenv.OpenInnerPile(); AddExtraLines(maxNumLines - numLines, ktagRightNonBoundary, vwenv); vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketUpHook); for (int i = 1; i < numLines - 1; i++) { vwenv.AddProp(ktagRightNonBoundary, this, kfragRightBracketExt); } vwenv.AddProp(ktagRightBoundary, this, kfragRightBracketLowHook); vwenv.CloseInnerPile(); } } else { // natural class context with segment-based natural class if (!isOuterIterCtxt) { OpenContextPile(vwenv); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftBracket); if (ncCtxt.FeatureStructureRAHvo != 0) { vwenv.AddObjProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragNC); } else { vwenv.AddProp((int)PhSimpleContextNC.PhSimpleContextNCTags.kflidFeatureStructure, this, kfragQuestions); } vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightBracket); if (!isOuterIterCtxt) { CloseContextPile(vwenv); } } break; case PhIterationContext.kclsidPhIterationContext: IPhIterationContext iterCtxt = ctxtOrVar as IPhIterationContext; if (iterCtxt.MemberRAHvo != 0) { int numLines = GetNumLines(iterCtxt.MemberRA as IPhSimpleContext); if (numLines > 1) { vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext); DisplayIterCtxt(iterCtxt, numLines, vwenv); } else { OpenContextPile(vwenv); if (iterCtxt.MemberRA.ClassID == PhSimpleContextNC.kclsidPhSimpleContextNC) { vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext); } else { vwenv.AddProp(ktagInnerNonBoundary, this, kfragLeftParen); vwenv.AddObjProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragContext); vwenv.AddProp(ktagInnerNonBoundary, this, kfragRightParen); } DisplayIterCtxt(iterCtxt, 1, vwenv); // Views doesn't handle selection properly when we have an inner pile with strings on either side, // so we don't add a zero-width space at the end CloseContextPile(vwenv, false); } } else { OpenContextPile(vwenv); vwenv.AddProp((int)PhIterationContext.PhIterationContextTags.kflidMember, this, kfragQuestions); CloseContextPile(vwenv); } break; case PhSimpleContextSeg.kclsidPhSimpleContextSeg: if (!isOuterIterCtxt) { OpenContextPile(vwenv); } if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure) != 0) { vwenv.AddObjProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragTerminalUnit); } else { vwenv.AddProp((int)PhSimpleContextSeg.PhSimpleContextSegTags.kflidFeatureStructure, this, kfragQuestions); } if (!isOuterIterCtxt) { CloseContextPile(vwenv); } break; case PhSimpleContextBdry.kclsidPhSimpleContextBdry: if (!isOuterIterCtxt) { OpenContextPile(vwenv); } if (m_cache.GetObjProperty(hvo, (int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure) != 0) { vwenv.AddObjProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragTerminalUnit); } else { vwenv.AddProp((int)PhSimpleContextBdry.PhSimpleContextBdryTags.kflidFeatureStructure, this, kfragQuestions); } if (!isOuterIterCtxt) { CloseContextPile(vwenv); } break; case PhVariable.kclsidPhVariable: OpenContextPile(vwenv); vwenv.AddProp(ktagXVariable, this, kfragXVariable); CloseContextPile(vwenv); break; } break; case kfragNC: int ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation); if (ncWs != 0) { vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, ncWs, this); } else { ncWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstAnal, hvo, (int)PhNaturalClass.PhNaturalClassTags.kflidName); if (ncWs != 0) { vwenv.AddStringAltMember((int)PhNaturalClass.PhNaturalClassTags.kflidName, ncWs, this); } else { vwenv.AddProp((int)PhNaturalClass.PhNaturalClassTags.kflidAbbreviation, this, kfragQuestions); } } break; case kfragTerminalUnit: int tuWs = m_cache.LangProject.ActualWs(LangProject.kwsFirstVern, hvo, (int)PhTerminalUnit.PhTerminalUnitTags.kflidName); if (tuWs != 0) { vwenv.AddStringAltMember((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, tuWs, this); } else { vwenv.AddProp((int)PhTerminalUnit.PhTerminalUnitTags.kflidName, this, kfragQuestions); } break; case kfragFeatNC: vwenv.AddObjProp((int)PhNCFeatures.PhNCFeaturesTags.kflidFeatures, this, kfragFeats); break; case kfragFeats: vwenv.AddObjVecItems((int)FsFeatStruc.FsFeatStrucTags.kflidFeatureSpecs, this, kfragFeature); break; case kfragFeature: vwenv.AddProp(ktagFeature, this, kfragFeatureLine); break; case kfragPlusVariable: vwenv.AddProp(ktagVariable, this, kfragPlusVariableLine); break; case kfragMinusVariable: vwenv.AddProp(ktagVariable, this, kfragMinusVariableLine); break; } }
private void MoveItem(object sender, TreeNode destNode, TreeNode sourceItem) { int hvoMove = (int)sourceItem.Tag; int hvoDest; int flidDest; FdoCache cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache"); string moveLabel = sourceItem.Text; TreeNodeCollection newSiblings; TreeView tree = sender as TreeView; if (destNode == null) { for (hvoDest = cache.GetOwnerOfObject(hvoMove); hvoDest != 0; hvoDest = cache.GetOwnerOfObject(hvoDest)) { if (cache.GetClassOfObject(hvoDest) == CmPossibilityList.kclsidCmPossibilityList) { break; } } if (hvoDest == 0) { return; } flidDest = (int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities; newSiblings = tree.Nodes; } else { hvoDest = (int)destNode.Tag; flidDest = (int)CmPossibility.CmPossibilityTags.kflidSubPossibilities; newSiblings = destNode.Nodes; } if (CheckAndReportForbiddenMove(hvoMove, hvoDest)) { return; } int hvoOldOwner = cache.GetOwnerOfObject(hvoMove); if (hvoOldOwner == hvoDest) { return; // nothing to do. } int flidSrc = cache.GetOwningFlidOfObject(hvoMove); int srcIndex = cache.GetObjIndex(hvoOldOwner, flidSrc, hvoMove); int ihvoDest = 0; for (; ihvoDest < newSiblings.Count; ihvoDest++) { if (newSiblings[ihvoDest].Text.CompareTo(moveLabel) > 0) // Enhance JohnT: use ICU comparison... { break; } } using (new RecordClerk.ListUpdateHelper(m_list, tree.TopLevelControl)) using (UndoRedoTaskHelper urth = new UndoRedoTaskHelper(cache, xWorksStrings.UndoMoveItem, xWorksStrings.RedoMoveItem)) { // Note: use MoveOwningSequence off FdoCache, so we get propchanges that can be picked up by SyncWatcher (CLE-76) // (Hopefully the propchanges won't cause too much intermediant flicker, // before ListUpdateHelper calls ReloadList()) cache.MoveOwningSequence(hvoOldOwner, flidSrc, srcIndex, srcIndex, hvoDest, flidDest, ihvoDest); ICmObject obj = CmObject.CreateFromDBObject(cache, hvoMove); obj.MoveSideEffects(hvoOldOwner); } }
public int Compare(object x1, object y1) { ManyOnePathSortItem x = x1 as ManyOnePathSortItem; ManyOnePathSortItem y = y1 as ManyOnePathSortItem; int hvoX = x.KeyObject; // CmBaseAnnotations int hvoY = y.KeyObject; int hvoParaX = m_cache.GetObjProperty(hvoX, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject); int hvoParaY = m_cache.GetObjProperty(hvoY, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject); if (hvoParaX == hvoParaY) { // Compare begin offsets and return int offsetX = m_cache.GetIntProperty(hvoX, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset); int offsetY = m_cache.GetIntProperty(hvoY, (int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset); return(offsetX - offsetY); } // Enhance: do something about picture captions?? // While owning objects are the same type, get the owner of each, if they are the same, // compare their position in owner. Special case to put heading before body. // If owners are not the same type, do some trick that will make FLEx texts come before Scripture. int hvoObjX = hvoParaX; int hvoObjY = hvoParaY; do { int hvoOwnerX = m_cache.GetOwnerOfObject(hvoObjX); int hvoOwnerY = m_cache.GetOwnerOfObject(hvoObjY); if (hvoOwnerX == 0) { if (hvoOwnerY == 0) { return(hvoY - hvoX); // totally arbitrary but at least consistent } return(-1); // also arbitrary } if (hvoOwnerY == 0) { return(1); // arbitrary, object with shorter chain comes first. } if (hvoOwnerX == hvoOwnerY) { int flidX = m_cache.GetOwningFlidOfObject(hvoObjX); int flidY = m_cache.GetOwningFlidOfObject(hvoObjY); if (flidX != flidY) { return(flidX - flidY); // typically body and heading. } int indexX = m_cache.GetObjIndex(hvoOwnerX, flidX, hvoObjX); int indexY = m_cache.GetObjIndex(hvoOwnerY, flidY, hvoObjY); return(indexX - indexY); } int clsX = m_cache.GetClassOfObject(hvoOwnerX); int clsY = m_cache.GetClassOfObject(hvoOwnerY); if (clsX != clsY) { // Typically one is in Scripture, the other in a Text. // Arbitrarily order things by the kind of parent they're in. // Enhance JohnT: this will need improvement if we go to hierarchical // structures like nested sections or a folder organization of texts. // We could loop all the way up, and then back down till we find a pair // of owners that are different. // (We reverse the usual X - Y in order to put Texts before Scripture // in this list as in the Texts list in FLEx.) return(clsY - clsX); } hvoObjX = hvoOwnerX; hvoObjY = hvoOwnerY; } while (true); // We'll eventually reach the top of the ownership hierarchy. }
private Set <int> GetDescendents(int hvoCommonAncestor, int relativesFlid) { string listPropertyName = Cache.MetaDataCacheAccessor.GetFieldName((uint)relativesFlid); string parentObjName = Cache.MetaDataCacheAccessor.GetClassName((uint)m_cache.GetClassOfObject(hvoCommonAncestor)); string xpathToPart = "./part[@id='" + parentObjName + "-Jt-" + listPropertyName + "']"; XmlNode pathSpec = m_parentToChildrenSpecs.SelectSingleNode(xpathToPart); if (pathSpec == null) { throw new ArgumentException("Expected to find part ({0}) in ParentClassPathsToChildren", xpathToPart); } // get the part spec that gives us the path from obsolete current (parent) list item object // to the new one. using (XmlBrowseViewBaseVc vc = new XmlBrowseViewBaseVc(m_cache, null)) { ManyOnePathSortItem parentItem = new ManyOnePathSortItem(hvoCommonAncestor, null, null); XmlBrowseViewBaseVc.ItemsCollectorEnv collector = new XmlBrowseViewBaseVc.ItemsCollectorEnv(null, m_cache, hvoCommonAncestor); vc.DisplayCell(parentItem, pathSpec, hvoCommonAncestor, collector); if (collector.HvosCollectedInCell != null && collector.HvosCollectedInCell.Count > 0) { return(collector.HvosCollectedInCell); } } return(new Set <int>()); }
protected override void ValidateSegForms(object expectedSegForm, object actualSegForm, string segFormContext) { string msg = "Mismatched {0} in {1}."; // Get the paragraph string corresponding to the annotation. ICmBaseAnnotation cbaExpected = CmBaseAnnotation.CreateFromDBObject(m_cache, (int)expectedSegForm); // first make sure we have a txt item. if (IsLineEnabled(InterlinLineChoices.kflidWord)) { ITsString tssExpectedForm = m_para.Contents.UnderlyingTsString.GetSubstring(cbaExpected.BeginOffset, cbaExpected.EndOffset); string lang = "xkal"; // Review: get WsLabel from tssExpectedForm. string actualForm = ""; if (cbaExpected.AnnotationTypeRAHvo == TwficAnnotationType) { actualForm = m_reader.GetItemInnerText(actualSegForm as XmlNode, "txt", lang); } else if (cbaExpected.AnnotationTypeRAHvo == PunctuationAnnotationType) { actualForm = m_reader.GetItemInnerText(actualSegForm as XmlNode, "punct", lang); } Assert.AreEqual(tssExpectedForm.Text, actualForm, String.Format(msg, "word", segFormContext)); } // if WordGloss is enabled, verify it. if (IsLineEnabled(InterlinLineChoices.kflidWordGloss)) { string lang = "en"; string actualWordGloss = m_reader.GetItemInnerText(actualSegForm as XmlNode, "gls", lang); if (cbaExpected.AnnotationTypeRAHvo == PunctuationAnnotationType) { // must be a punctuation (non-wfic) Assert.AreEqual("", actualWordGloss); } else { WfiGloss expectedGloss = null; int clsId = m_cache.GetClassOfObject(cbaExpected.InstanceOfRAHvo); if (clsId == WfiGloss.kclsidWfiGloss) { expectedGloss = new WfiGloss(m_cache, cbaExpected.InstanceOfRAHvo); } else if (clsId == WfiWordform.kclsidWfiWordform) { // should be a twfic so get its guess. StTxtPara.TwficInfo cbaInfo = new StTxtPara.TwficInfo(m_cache, cbaExpected.Hvo); int hvoExpectedGloss = cbaInfo.GetGuess(); if (hvoExpectedGloss != 0) { expectedGloss = new WfiGloss(m_cache, hvoExpectedGloss); } } // TODO: There are cases for other classes (e.g. WfiAnalysis) but // the tests do not generate those right now, so we won't worry about them right now. if (expectedGloss != null) { Assert.AreEqual(expectedGloss.Form.AnalysisDefaultWritingSystem, actualWordGloss); } else { Assert.AreEqual("", actualWordGloss); } } } // validate morph bundle lines. if (IsLineEnabled(InterlinLineChoices.kflidMorphemes) || IsLineEnabled(InterlinLineChoices.kflidLexEntries) || IsLineEnabled(InterlinLineChoices.kflidLexGloss) || IsLineEnabled(InterlinLineChoices.kflidLexPos)) { // compare exported document to the LexEntries information in the WfiAnalysis int hvoWfiAnalysis = 0; if (cbaExpected.AnnotationTypeRAHvo != PunctuationAnnotationType) { hvoWfiAnalysis = WfiAnalysis.GetWfiAnalysisFromInstanceOf(m_cache, cbaExpected.Hvo); } List <XmlNode> morphNodes = m_reader.GetMorphNodes(actualSegForm as XmlNode); if (hvoWfiAnalysis == 0) { // make sure we don't have any morphs. Assert.IsEmpty(morphNodes); } else { IWfiAnalysis wfiAnalysis = WfiAnalysis.CreateFromDBObject(m_cache, hvoWfiAnalysis); foreach (WfiMorphBundle morphBundle in wfiAnalysis.MorphBundlesOS) { int iMorph = morphBundle.OwnOrd - 1; string morphContext = segFormContext + "/Morph(" + iMorph + ")"; XmlNode actualMorphNode = iMorph < morphNodes.Count ? morphNodes[iMorph] : null; if (actualMorphNode == null) { Assert.Fail(String.Format(msg, "missing morph", morphContext)); } ITsString tssLexEntry = null; int hvoMorph = morphBundle.MorphRAHvo; if (hvoMorph != 0) { // first test the morph form if (IsLineEnabled(InterlinLineChoices.kflidMorphemes)) { string actualMorphForm = m_reader.GetItemInnerText(actualMorphNode as XmlNode, "txt", "xkal"); Assert.AreEqual(morphBundle.MorphRA.Form.VernacularDefaultWritingSystem, actualMorphForm, String.Format(msg, "morph/txt", morphContext)); } // next test the lex entry if (IsLineEnabled(InterlinLineChoices.kflidLexEntries)) { string actualLexEntry = m_reader.GetItemInnerText(actualMorphNode as XmlNode, "cf", "xkal"); string actualHomograph = m_reader.GetItemInnerText(actualMorphNode as XmlNode, "hn", "en"); string actualVariantTypes = m_reader.GetItemInnerText(actualMorphNode as XmlNode, "variantTypes", "en"); tssLexEntry = InterlinDocChild.GetLexEntryTss(m_cache, morphBundle, m_cache.DefaultVernWs); Assert.AreEqual(tssLexEntry.Text, actualLexEntry + actualHomograph + actualVariantTypes, String.Format(msg, "morph/cf[hn|variantTypes]", morphContext)); } if (IsLineEnabled(InterlinLineChoices.kflidLexGloss)) { string actualLexGloss = m_reader.GetItemInnerText(actualMorphNode as XmlNode, "gls", "en"); string expectedGloss = ""; if (morphBundle.SenseRA != null && morphBundle.SenseRA.Gloss != null) { expectedGloss = morphBundle.SenseRA.Gloss.AnalysisDefaultWritingSystem; } Assert.AreEqual(expectedGloss, actualLexGloss, String.Format(msg, "morph/gls", morphContext)); } if (IsLineEnabled(InterlinLineChoices.kflidLexPos)) { string actualLexMsa = m_reader.GetItemInnerText(actualMorphNode as XmlNode, "msa", "en"); string expectedMsa = ""; if (morphBundle.SenseRA != null && morphBundle.SenseRA.MorphoSyntaxAnalysisRA != null) { expectedMsa = morphBundle.SenseRA.MorphoSyntaxAnalysisRA.InterlinearAbbr; } Assert.AreEqual(expectedMsa, actualLexMsa, String.Format(msg, "morph/msa", morphContext)); } } } Assert.AreEqual(wfiAnalysis.MorphBundlesOS.Count, morphNodes.Count); } } }