Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions flexlibs2/code/Grammar/GramCatOperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,11 +519,8 @@ def Duplicate(self, item_or_hvo, insert_after=True, deep=False):
feature_system = self.project.lp.MsFeatureSystemOA
factory = self.project.project.ServiceLocator.GetService(IFsFeatStrucTypeFactory)
duplicate = factory.Create()
if insert_after:
source_index = feature_system.TypesOC.IndexOf(source)
feature_system.TypesOC.Insert(source_index + 1, duplicate)
else:
feature_system.TypesOC.Add(duplicate)
# TypesOC is unordered (OC); insert_after is a no-op, add at end
feature_system.TypesOC.Add(duplicate)

# Copy simple MultiString properties (AFTER adding to parent)
duplicate.Name.CopyAlternatives(source.Name)
Expand Down
6 changes: 3 additions & 3 deletions flexlibs2/code/Lexicon/allomorph.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def form(self) -> str:
form_multistring = self._obj.Form
if form_multistring:
# Get from default vernacular writing system
default_ws = self._obj.OwnerOfClass.project.DefaultVernWs
default_ws = self._obj.Cache.DefaultVernWs
form_text = ITsString(form_multistring.get_String(default_ws)).Text
return normalize_text(form_text)
return ""
Expand Down Expand Up @@ -160,7 +160,7 @@ def gloss(self) -> str:

if hasattr(self._concrete, "Gloss") and self._concrete.Gloss:
# Get from default analysis writing system
default_ws = self._obj.OwnerOfClass.project.DefaultAnalWs
default_ws = self._obj.Cache.DefaultAnalWs
gloss_text = ITsString(self._concrete.Gloss.get_String(default_ws)).Text
return normalize_text(gloss_text)
return ""
Expand Down Expand Up @@ -275,7 +275,7 @@ def stem_name(self):

if hasattr(self._concrete, "StemName") and self._concrete.StemName:
# Get from default analysis writing system
default_ws = self._obj.OwnerOfClass.project.DefaultAnalWs
default_ws = self._obj.Cache.DefaultAnalWs
stem_name_text = ITsString(self._concrete.StemName.get_String(default_ws)).Text
return normalize_text(stem_name_text)
return ""
Expand Down
7 changes: 2 additions & 5 deletions flexlibs2/code/Notebook/DataNotebookOperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2538,11 +2538,8 @@ def Duplicate(self, record_or_hvo, insert_after=True, deep=True):
else:
# Parent is the top-level repository
repos = self.project.project.ServiceLocator.GetService(IRnResearchNbkRepository)
if insert_after:
source_index = repos.RecordsOC.IndexOf(source)
repos.RecordsOC.Insert(source_index + 1, duplicate)
else:
repos.RecordsOC.Add(duplicate)
# RecordsOC is unordered (OC); insert_after is a no-op, add at end
repos.RecordsOC.Add(duplicate)

# Copy simple MultiString properties
duplicate.Title.CopyAlternatives(source.Title)
Expand Down
4 changes: 2 additions & 2 deletions flexlibs2/code/Notebook/NoteOperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ def Duplicate(self, item_or_hvo, insert_after=True, deep=True):
source_index = parent.RepliesOS.IndexOf(source)
parent.RepliesOS.Insert(source_index + 1, duplicate)
elif hasattr(parent, "AnnotationsOC"):
source_index = parent.AnnotationsOC.IndexOf(source)
parent.AnnotationsOC.Insert(source_index + 1, duplicate)
# AnnotationsOC is unordered (OC); insert_after is a no-op, add at end
parent.AnnotationsOC.Add(duplicate)
else:
# Insert at end
if hasattr(parent, "RepliesOS"):
Expand Down
12 changes: 3 additions & 9 deletions flexlibs2/code/TextsWords/DiscourseOperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,15 +1096,9 @@ def Duplicate(self, item_or_hvo, insert_after=True, deep=True):
duplicate = factory.Create()

# ADD TO PARENT FIRST
if insert_after:
# Insert after source chart
if hasattr(parent, "ChartsOC"):
source_index = parent.ChartsOC.IndexOf(source)
parent.ChartsOC.Insert(source_index + 1, duplicate)
else:
# Insert at end
if hasattr(parent, "ChartsOC"):
parent.ChartsOC.Add(duplicate)
# ChartsOC is unordered (OC); insert_after is a no-op, add at end
if hasattr(parent, "ChartsOC"):
parent.ChartsOC.Add(duplicate)

# Copy MultiString properties (AFTER adding to parent)
if hasattr(source, "Name") and source.Name:
Expand Down
9 changes: 2 additions & 7 deletions flexlibs2/code/TextsWords/WfiAnalysisOperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,8 @@ def Duplicate(self, item_or_hvo, insert_after=True, deep=False):
duplicate = factory.Create()

# Determine insertion position
if insert_after:
# Insert after source analysis
source_index = list(parent.AnalysesOC).index(source)
parent.AnalysesOC.Insert(source_index + 1, duplicate)
else:
# Insert at end
parent.AnalysesOC.Add(duplicate)
# AnalysesOC is unordered (OC); insert_after is a no-op, add at end
parent.AnalysesOC.Add(duplicate)

# Copy Reference Atomic (RA) properties
if hasattr(source, "CategoryRA") and source.CategoryRA:
Expand Down
3 changes: 2 additions & 1 deletion flexlibs2/code/TextsWords/WfiGlossOperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ def Duplicate(self, item_or_hvo, insert_after=False):
factory = self.project.project.ServiceLocator.GetService(IWfiGlossFactory)
duplicate = factory.Create()

# MeaningsOC is unordered; always append via Add().
# Determine insertion position
# MeaningsOC is unordered (OC); insert_after is a no-op, add at end
parent.MeaningsOC.Add(duplicate)

# Copy simple MultiString properties
Expand Down
6 changes: 3 additions & 3 deletions flexlibs2/code/lcm_casting.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ def clone_properties(source_obj, dest_obj, project=None):
source = cast_to_concrete(source_obj)
dest = cast_to_concrete(dest_obj)

# If project not provided, try to get it from the destination object
if project is None and hasattr(dest, "OwnerOfClass"):
# If project not provided, resolve via Cache.LanguageProject (canonical accessor)
if project is None and hasattr(dest, "Cache"):
try:
project = dest.OwnerOfClass.project
project = dest.Cache.LanguageProject
except Exception:
pass

Expand Down
Loading