|
3 | 3 | // (http://www.gnu.org/licenses/lgpl-2.1.html) |
4 | 4 |
|
5 | 5 | //#define TraceMouseCalls // uncomment this line to trace mouse messages |
6 | | -using System; |
7 | | -using System.Collections.Generic; |
8 | | -using System.Drawing; |
9 | | -using System.Linq; |
10 | | -using System.Windows.Forms; |
11 | | -using System.Diagnostics; |
12 | | -using System.Text; |
13 | | -using SIL.LCModel; |
14 | | -using SIL.FieldWorks.Common.RootSites; |
15 | | -using SIL.LCModel.Utils; |
| 6 | +using Icu.Collation; |
16 | 7 | using SIL.FieldWorks.Common.FwUtils; |
| 8 | +using SIL.FieldWorks.Common.RootSites; |
17 | 9 | using SIL.FieldWorks.Common.ViewsInterfaces; |
18 | | -using SIL.FieldWorks.FdoUi; |
19 | 10 | using SIL.FieldWorks.Common.Widgets; |
20 | | -using SIL.LCModel.DomainServices; |
21 | | -using SIL.LCModel.Infrastructure; |
| 11 | +using SIL.FieldWorks.FdoUi; |
| 12 | +using SIL.LCModel; |
22 | 13 | using SIL.LCModel.Core.Cellar; |
23 | | -using SIL.LCModel.Core.Text; |
24 | 14 | using SIL.LCModel.Core.KernelInterfaces; |
| 15 | +using SIL.LCModel.Core.Text; |
| 16 | +using SIL.LCModel.DomainServices; |
| 17 | +using SIL.LCModel.Infrastructure; |
| 18 | +using SIL.LCModel.Utils; |
25 | 19 | using SIL.PlatformUtilities; |
26 | | -using XCore; |
27 | 20 | using SIL.WritingSystems; |
28 | | -using Icu.Collation; |
| 21 | +using System; |
| 22 | +using System.Collections.Generic; |
| 23 | +using System.Diagnostics; |
| 24 | +using System.Drawing; |
| 25 | +using System.Linq; |
| 26 | +using System.Text; |
| 27 | +using System.Windows.Forms; |
| 28 | +using XCore; |
29 | 29 |
|
30 | 30 | namespace SIL.FieldWorks.IText |
31 | 31 | { |
@@ -1656,6 +1656,43 @@ private int CreateSecondaryAndCopyStrings(int flidChoices, int hvoMain, int flid |
1656 | 1656 | m_caches.MainCache.MainCacheAccessor, m_caches.DataAccess as IVwCacheDa); |
1657 | 1657 | } |
1658 | 1658 |
|
| 1659 | + public void UpdateField(int hvo, int flid) |
| 1660 | + { |
| 1661 | + CheckDisposed(); |
| 1662 | + if (!m_cache.ServiceLocator.IsValidObjectId(hvo)) |
| 1663 | + { |
| 1664 | + return; |
| 1665 | + } |
| 1666 | + ICmObject hvoObject = Caches.MainCache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvo); |
| 1667 | + if (hvoObject is ILexSense lexSense) |
| 1668 | + { |
| 1669 | + // This lex sense changed. Update morphs that use it. |
| 1670 | + foreach (int hvoMorph in GetHvoMorphsForLexSense(hvo)) |
| 1671 | + { |
| 1672 | + // This fixes LT-22534. |
| 1673 | + EstablishDefaultSense(hvoMorph, lexSense.Entry, lexSense, null); |
| 1674 | + } |
| 1675 | + } |
| 1676 | + if (hvoObject != null && hvoObject.Owner is IMoMorphSynAnalysis msa) |
| 1677 | + { |
| 1678 | + if (msa.Owner is ILexEntry entry) |
| 1679 | + { |
| 1680 | + foreach (var sense in entry.AllSenses) |
| 1681 | + { |
| 1682 | + if (sense.MorphoSyntaxAnalysisRA == msa) |
| 1683 | + { |
| 1684 | + // This lex sense changed. Update morphs that use it. |
| 1685 | + foreach (int hvoMorph in GetHvoMorphsForLexSense(sense.Hvo)) |
| 1686 | + { |
| 1687 | + // This fixes LT-22541. |
| 1688 | + EstablishDefaultSense(hvoMorph, entry, sense, null); |
| 1689 | + } |
| 1690 | + } |
| 1691 | + } |
| 1692 | + } |
| 1693 | + } |
| 1694 | + } |
| 1695 | + |
1659 | 1696 | /// <summary> |
1660 | 1697 | /// Set the (real) LexEntry that is considered current. Broadcast a notification |
1661 | 1698 | /// to delegates if it changed. |
@@ -3956,6 +3993,22 @@ protected List<int> LexSensesForCurrentMorphs() |
3956 | 3993 | return lexSensesForMorphs; |
3957 | 3994 | } |
3958 | 3995 |
|
| 3996 | + private IList<int> GetHvoMorphsForLexSense(int lexSense) |
| 3997 | + { |
| 3998 | + IList<int> hvoMorphs = new List<int>(); |
| 3999 | + int cmorphs = m_caches.DataAccess.get_VecSize(kSbWord, ktagSbWordMorphs); |
| 4000 | + for (int i = 0; i < cmorphs; i++) |
| 4001 | + { |
| 4002 | + int hvoMorph = m_caches.DataAccess.get_VecItem(kSbWord, ktagSbWordMorphs, i); |
| 4003 | + int hvoMorphSense = m_caches.DataAccess.get_ObjectProp(hvoMorph, ktagSbMorphGloss); |
| 4004 | + if (m_caches.RealHvo(hvoMorphSense) == lexSense) |
| 4005 | + { |
| 4006 | + hvoMorphs.Add(hvoMorph); |
| 4007 | + } |
| 4008 | + } |
| 4009 | + return hvoMorphs; |
| 4010 | + } |
| 4011 | + |
3959 | 4012 | /// <summary> |
3960 | 4013 | /// get the current dummy sandbox morphs |
3961 | 4014 | /// </summary> |
|
0 commit comments