protected InterlinearExporter(FdoCache cache, XmlWriter writer, ICmObject objRoot,
                                      InterlinLineChoices lineChoices, InterlinVc vc)
            : base(null, cache.MainCacheAccessor, objRoot.Hvo)
        {
            m_cache            = cache;
            m_writer           = writer;
            m_flidStTextTitle  = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Title", false);
            m_flidStTextSource = m_cache.MetaDataCacheAccessor.GetFieldId("StText", "Source", false);
            m_vc = vc;
            SetTextTitleAndMetadata(objRoot as IStText);

            // Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
            IMoMorphType mmtStem;
            IMoMorphType mmtPrefix;
            IMoMorphType mmtSuffix;
            IMoMorphType mmtInfix;
            IMoMorphType mmtBoundStem;
            IMoMorphType mmtSimulfix;
            IMoMorphType mmtSuprafix;

            m_cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetMajorMorphTypes(
                out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
                out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic,
                out mmtSimulfix, out mmtSuprafix);

            m_wsManager = m_cache.ServiceLocator.WritingSystemManager;
            m_repoObj   = m_cache.ServiceLocator.GetInstance <ICmObjectRepository>();
        }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            base.Dispose(disposing);

            if (disposing)
            {
                //RightMouseClickedEvent -= new FwRightMouseClickEventHandler(InterlinDocChild_RightMouseClickedEvent);
                if (m_oneAnalSandbox != null)
                {
                    if (!Controls.Contains(m_oneAnalSandbox))
                    {
                        m_oneAnalSandbox.Dispose();
                    }
                }
                if (m_vc != null)
                {
                    m_vc.Dispose();
                }
            }
            m_oneAnalSandbox    = null;
            m_vc                = null;
            m_configurationNode = null;
            m_wordform          = null;
        }
Example #3
0
        protected InterlinearExporter(FdoCache cache, XmlWriter writer, int hvoRoot, InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
            : base(null, cache.MainCacheAccessor, hvoRoot)
        {
            m_cache                = cache;
            m_writer               = writer;
            ktagParaSegments       = InterlinVc.ParaSegmentTag(cache);
            ktagSegmentForms       = InterlinVc.SegmentFormsTag(cache);
            m_flidStringValue      = CmBaseAnnotation.StringValuePropId(cache);
            m_lineChoices          = lineChoices;
            m_defaultGlossVirtFlid = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiMorphBundle", "DefaultSense");
            m_vc = vc;
            m_tssPendingTitle      = tssTextName;
            m_tssTitleAbbreviation = tssTextAbbreviation;

            // Get morphtype information that we need later.  (plus stuff we don't...)  See LT-8288.
            IMoMorphType mmtStem;
            IMoMorphType mmtPrefix;
            IMoMorphType mmtSuffix;
            IMoMorphType mmtInfix;
            IMoMorphType mmtBoundStem;
            IMoMorphType mmtSimulfix;
            IMoMorphType mmtSuprafix;

            MoMorphType.GetMajorMorphTypes(cache, out mmtStem, out mmtPrefix, out mmtSuffix, out mmtInfix,
                                           out mmtBoundStem, out m_mmtProclitic, out m_mmtEnclitic, out mmtSimulfix, out mmtSuprafix);
        }
Example #4
0
 internal MockInterlinDocForAnalyis(IStText testText)
 {
     Cache         = testText.Cache;
     m_hvoRoot     = testText.Hvo;
     m_testText    = testText;
     m_vc          = new InterlinVc(Cache);
     m_vc.RootSite = this;
 }
Example #5
0
 internal FreeformAdder(int hvoType, RootSite site, bool fNeedReconstruct, InterlinVc vc) : base(site.Cache)
 {
     m_hvoType          = hvoType;
     m_site             = site;
     m_fNeedReconstruct = fNeedReconstruct;
     m_choices          = vc.LineChoices;
     m_vc = vc;
 }
Example #6
0
        public InterlinearExportDialog(Mediator mediator, PropertyTable propertyTable, ICmObject objRoot, InterlinVc vc)
            : base(mediator, propertyTable)
        {
            m_objRoot = objRoot;
            m_vc      = vc;

            m_helpTopic        = "khtpExportInterlinear";
            columnHeader1.Text = ITextStrings.ksFormat;
            columnHeader2.Text = ITextStrings.ksExtension;
            // ReSharper disable once VirtualMemberCallInConstructor
            Text = ITextStrings.ksExportInterlinear;
        }
Example #7
0
        public override void FixtureSetup()
        {
            CheckDisposed();
            base.FixtureSetup();

            m_textsDefn   = new XmlDocument();
            m_exportedXml = new XmlDocument();

            InstallVirtuals(@"Language Explorer\Configuration\Main.xml",
                            new string[] { "SIL.FieldWorks.FDO.", "SIL.FieldWorks.IText." });
            m_vc = new InterlinVc(Cache);
        }
 public static InterlinearExporter Create(string mode, FdoCache cache, XmlWriter writer, ICmObject objRoot,
                                          InterlinLineChoices lineChoices, InterlinVc vc)
 {
     if (mode != null && mode.ToLowerInvariant() == "elan")
     {
         return(new InterlinearExporterForElan(cache, writer, objRoot, lineChoices, vc));
     }
     else
     {
         return(new InterlinearExporter(cache, writer, objRoot, lineChoices, vc));
     }
 }
Example #9
0
        public InterlinearExportDialog(Mediator mediator, ICmObject objRoot, InterlinVc vc, IBookImporter bookImporter)
            : base(mediator)
        {
            m_objRoot      = objRoot;
            m_vc           = vc;
            m_bookImporter = bookImporter;

            m_helpTopic        = "khtpExportInterlinear";
            columnHeader1.Text = ITextStrings.ksFormat;
            columnHeader2.Text = ITextStrings.ksExtension;
            Text = ITextStrings.ksExportInterlinear;
            OnLaunchFilterScrScriptureSectionsDialog += LaunchFilterTextsDialog;
        }
Example #10
0
 public static InterlinearExporter Create(string mode, FdoCache cache, XmlWriter writer, int hvoRoot,
                                          InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
 {
     if (mode != null && mode.ToLowerInvariant() == "elan")
     {
         return(new InterlinearExporterForElan(cache, writer, hvoRoot, lineChoices, vc, tssTextName,
                                               tssTextAbbreviation));
     }
     else
     {
         return(new InterlinearExporter(cache, writer, hvoRoot, lineChoices, vc, tssTextName, tssTextAbbreviation));
     }
 }
Example #11
0
 public override void Initialize()
 {
     CheckDisposed();
     base.Initialize();
     m_inMemoryCache.InitializeAnnotationDefs();
     InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
                     new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });
     m_text = new Text();
     Cache.LangProject.TextsOC.Add(m_text);
     m_para            = new ScrTxtPara();
     m_stText          = new StText();
     m_text.ContentsOA = m_stText;
     m_stText.ParagraphsOS.Append(m_para);
     ktagParaSegments = InterlinVc.ParaSegmentTag(Cache);
     m_wsVern         = Cache.DefaultVernWs;
 }
        public InterlinearExportDialog(Mediator mediator, int hvoRoot, InterlinVc vc, List <int> scrHvos)
            : base(mediator)
        {
            m_hvoRoot = hvoRoot;
            m_vc      = vc;
            m_scrHvos = scrHvos;

            m_helpTopic        = "khtpExportInterlinear";
            columnHeader1.Text = ITextStrings.ksFormat;
            columnHeader2.Text = ITextStrings.ksExtension;
            GetTextProps();
            Text = ITextStrings.ksExportInterlinear;
            if (MiscUtils.IsTEInstalled)
            {
                OnLaunchFilterScrScriptureSectionsDialog += new EventHandler(LaunchFilterScrScriptureSectionsDialog);
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Make the root box.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void MakeRoot()
        {
            CheckDisposed();

            if (m_fdoCache == null || DesignMode)
            {
                return;
            }

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

            m_vc = new InterlinVc(m_fdoCache);
            // Theory has it that the slices that have 'true' in this attribute will allow the sandbox to be used.
            // We'll see how the theory goes, when I get to the point of wanting to see the sandbox.
            m_vc.ShowMorphBundles = true;
            m_vc.ShowDefaultSense = true;

            m_vc.LineChoices = new EditableInterlinLineChoices(m_fdoCache.LanguageProject, WritingSystemServices.kwsFirstVern,
                                                               m_fdoCache.DefaultAnalWs);
            m_vc.LineChoices.Add(InterlinLineChoices.kflidWord);             // 1
            m_vc.LineChoices.Add(InterlinLineChoices.kflidMorphemes);        // 2
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexEntries);       //3
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexGloss);         //4
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexPos);           //5

            m_rootb.DataAccess = m_fdoCache.MainCacheAccessor;
            FixWs();             // AFTER setting DA!

            if (m_wordform != null)
            {
                m_rootb.SetRootObject(m_wordform.Hvo, m_vc, m_kfragSingleInterlinearAnalysisWithLabels, m_styleSheet);
            }

            base.MakeRoot();

            SetSandboxSize();             // in case we already have a current annotation.
            SetBackgroundColor();
            m_fRootMade = true;
        }
Example #14
0
        /// <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);
        }
Example #15
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_vc != null)
                {
                    m_vc.Dispose();
                }
                if (m_writer != null)
                {
                    m_writer.Close();
                }
                if (m_stream != null)
                {
                    m_stream.Close();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_vc          = null;
            m_textsDefn   = null;
            m_text1       = null;
            m_exportedXml = null;
            m_writer      = null;
            m_exporter    = null;
            m_choices     = null;
            m_stream      = null;

            base.Dispose(disposing);
        }
Example #16
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        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)
            {
                if (m_oneAnalSandbox != null)
                {
                    m_oneAnalSandbox.SizeChanged -= HandleSandboxSizeChanged;
                }
            }

            base.Dispose(disposing);

            if (disposing)
            {
                if (m_oneAnalSandbox != null)
                {
                    m_oneAnalSandbox.Dispose();
                }
                if (m_vc != null)
                {
                    m_vc.Dispose();
                }
            }
            m_oneAnalSandbox    = null;
            m_vc                = null;
            m_configurationNode = null;
            m_wordform          = null;
            m_wfiAnalysis       = null;
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Make the root box.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void MakeRoot()
        {
            CheckDisposed();

            if (m_fdoCache == null || DesignMode)
            {
                return;
            }

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

            m_vc = new InterlinVc(m_fdoCache);
            // Theory has it that the slices that have 'true' in this attribute will allow the sandbox to be used.
            // We'll see how the theory goes, when I get to the point of wanting to see the sandbox.
            var isEditable = IsEditable;

            m_vc.ShowMorphBundles = true;
            m_vc.ShowDefaultSense = true;
            // JohnT: kwsVernInParagraph is rather weird here, where we don't have a paragraph, but it allows the
            // VC to deduce the WS of the wordform, not from the paragraph, but from the best vern WS of the wordform itself.
            if (isEditable)
            {
                m_vc.LineChoices = new EditableInterlinLineChoices(m_fdoCache.LanguageProject, WritingSystemServices.kwsVernInParagraph,
                                                                   m_fdoCache.DefaultAnalWs);
            }
            else
            {
                m_vc.LineChoices = new InterlinLineChoices(m_fdoCache.LanguageProject, WritingSystemServices.kwsVernInParagraph,
                                                           m_fdoCache.DefaultAnalWs);
            }
            m_vc.LineChoices.Add(InterlinLineChoices.kflidMorphemes);          // 1
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexEntries);         //2
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexGloss);           //3
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexPos);             //4

            m_rootb.DataAccess = m_fdoCache.MainCacheAccessor;
            FixWs();             // AFTER setting DA!

            const int selectorId = InterlinVc.kfragSingleInterlinearAnalysisWithLabelsLeftAlign;

            if (m_wfiAnalysis != null)
            {
                m_rootb.SetRootObject(m_wfiAnalysis.Hvo, m_vc, selectorId, m_styleSheet);
            }

            base.MakeRoot();

            if (!IsEditable)
            {
                return;
            }

            m_oneAnalSandbox = new OneAnalysisSandbox(m_fdoCache,
                                                      Mediator,
                                                      StyleSheet,
                                                      m_vc.LineChoices,
                                                      m_wfiAnalysis.Hvo)
            {
                Visible = false
            };
            Controls.Add(m_oneAnalSandbox);
            if (m_oneAnalSandbox.RootBox == null)
            {
                m_oneAnalSandbox.MakeRoot();                    // adding sandbox to Controls doesn't make rootbox.
            }
            InitSandbox();
            m_oneAnalSandbox.SizeChanged += (HandleSandboxSizeChanged);
            if (m_fSliceIsCurrent)
            {
                TurnOnSandbox();
            }
        }
 protected internal InterlinearExporterForElan(FdoCache cache, XmlWriter writer, ICmObject objRoot,
                                               InterlinLineChoices lineChoices, InterlinVc vc)
     : base(cache, writer, objRoot, lineChoices, vc)
 {
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Make the root box.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public override void MakeRoot()
        {
            CheckDisposed();

            if (m_fdoCache == null || DesignMode)
            {
                return;
            }

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

            m_vc = new InterlinVc(m_fdoCache);
            // Theory has it that the slices that have 'true' in this attribute will allow the sandbox to be used.
            // We'll see how the theory goes, when I get to the point of wanting to see the sandbox.
            bool isEditable = IsEditable;

            m_vc.ShowMorphBundles = true;
            m_vc.ShowDefaultSense = true;
            // JohnT: kwsVernInParagraph is rather weird here, where we don't have a paragraph, but it allows the
            // VC to deduce the WS of the wordform, not from the paragraph, but from the best vern WS of the wordform itself.
            if (isEditable)
            {
                m_vc.LineChoices = new EditableInterlinLineChoices(LangProject.kwsVernInParagraph, m_fdoCache.DefaultAnalWs);
            }
            else
            {
                m_vc.LineChoices = new InterlinLineChoices(LangProject.kwsVernInParagraph, m_fdoCache.DefaultAnalWs);
            }
            m_vc.LineChoices.Add(InterlinLineChoices.kflidMorphemes);          // 1
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexEntries);         //2
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexGloss);           //3
            m_vc.LineChoices.Add(InterlinLineChoices.kflidLexPos);             //4

            m_rootb.DataAccess = m_fdoCache.MainCacheAccessor;
            FixWs();                 // AFTER setting DA!

            int selectorId = 100034; //Convert.ToInt32(XmlUtils.GetManditoryAttributeValue(m_configurationNode.SelectSingleNode("deParams"), "selector"));

            if (m_hvoWfiAnalysis != 0)
            {
                m_rootb.SetRootObject(m_hvoWfiAnalysis, m_vc, selectorId, m_styleSheet);
            }

            base.MakeRoot();

            if (IsEditable)
            {
                m_oneAnalSandbox = new OneAnalysisSandbox(m_fdoCache,
                                                          Mediator,
                                                          StyleSheet,
                                                          m_vc.LineChoices,
                                                          m_hvoWfiAnalysis);
                m_oneAnalSandbox.Visible = false;
                Controls.Add(m_oneAnalSandbox);
                if (m_oneAnalSandbox.RootBox == null)
                {
                    m_oneAnalSandbox.MakeRoot();                        // adding sandbox to Controls doesn't make rootbox.
                }
                m_tag = MeVirtualHandler.InstallMe(Cache.VwCacheDaAccessor).Tag;
                InitSandbox();
                m_oneAnalSandbox.SizeChanged += (HandleSandboxSizeChanged);
            }
        }
Example #20
0
 protected internal InterlinearExporterForElan(FdoCache cache, XmlWriter writer, int hvoRoot, InterlinLineChoices lineChoices, InterlinVc vc, ITsString tssTextName, ITsString tssTextAbbreviation)
     : base(cache, writer, hvoRoot, lineChoices, vc, tssTextName, tssTextAbbreviation)
 {
     kPunctuationAnnType = CmAnnotationDefn.Punctuation(cache).Hvo;
 }