Skip to content

Commit

Permalink
Added protection for empty records (individual, notes and multimedia)…
Browse files Browse the repository at this point in the history
… in files from other programs (fix #605)
  • Loading branch information
Serg-Norseman committed Nov 24, 2024
1 parent 1e07638 commit d3ea54b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions locales/help_enu/gkhHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>Change log</h1>

<p>
<b>??.??.2024 [v2.32.0 &amp; v3.8.0]</b><ul>
<li>Added protection for empty records (individual, notes and multimedia) in files from other programs.
<li>Added option in tree diagrams - use additional dates (baptism, burial) if the main ones (births, deaths) are missing.
<li>Added options in tree diagrams: text paddings, date designations and mourning edges.
<li>Added text effect options in tree diagrams (GKv2 only).
Expand Down
1 change: 1 addition & 0 deletions locales/help_rus/gkhHistory.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>История версий</h1>

<p>
<b>??.??.2024 [v2.32.0 &amp; v3.8.0]</b><ul>
<li>Добавлена защита пустых записей (персональных, заметок и мультимедиа) в файлах из сторонних программ.
<li>Добавлена опция в диаграммах деревьев - использовать дополнительные даты (крещения и похорон), если отсутствуют основные (рождения, смерти).
<li>Добавлены опции в диаграммах деревьев: отступа текста, обозначений дат и траурных рамок.
<li>Добавлены опции эффектов текста в диаграммах деревьев (только GKv2).
Expand Down
31 changes: 31 additions & 0 deletions projects/GKCore/GDModel/Providers/GEDCOM/GEDCOMChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ namespace GDModel.Providers.GEDCOM
/// </summary>
public class GEDCOMChecker
{
private const string EmptyRecordContent = "---";

private readonly IBaseContext fBaseContext;
private readonly GEDCOMFormat fFormat;
private readonly IProgressController fProgress;
Expand Down Expand Up @@ -291,6 +293,14 @@ private void CheckIndividualRecord(GDMIndividualRecord iRec)
iRec.DeleteTag("_FSFTID");
}
}

// Empty records in files from other programs
if (iRec.PersonalNames.Count == 0) {
var name = new GDMPersonalName();
// when saving protection from skipping
name.Given = EmptyRecordContent;
iRec.PersonalNames.Add(name);
}
}

private void CheckChildLink(GDMFamilyRecord fam, int index)
Expand Down Expand Up @@ -393,6 +403,23 @@ private void CheckMultimediaRecord(GDMMultimediaRecord mmRec, int fileVer)
}
}
}

// Empty records in files from other programs
if (mmRec.FileReferences.Count == 0) {
var fileRef = new GDMFileReferenceWithTitle();
// when saving protection from skipping
fileRef.Title = EmptyRecordContent;
mmRec.FileReferences.Add(fileRef);
}
}

private void CheckNoteRecord(GDMNoteRecord noteRec, int fileVer)
{
// Empty records in files from other programs
if (noteRec.Lines.Count == 0) {
// when saving protection from skipping
noteRec.Lines.Text = EmptyRecordContent;
}
}

private void CheckRecord(GDMRecord rec, int fileVer)
Expand Down Expand Up @@ -429,6 +456,10 @@ private void CheckRecord(GDMRecord rec, int fileVer)
case GDMRecordType.rtMultimedia:
CheckMultimediaRecord(rec as GDMMultimediaRecord, fileVer);
break;

case GDMRecordType.rtNote:
CheckNoteRecord(rec as GDMNoteRecord, fileVer);
break;
}
}

Expand Down
4 changes: 0 additions & 4 deletions projects/GKCore/GKCore/Lists/MultimediaListModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ public override void Fetch(GDMMultimediaRecord aRec)

protected override object GetColumnValueEx(int colType, int colSubtype, bool isVisible)
{
if (fFileRef == null) {
return null;
}

object result = null;
switch ((ColumnType)colType) {
case ColumnType.ctXRefNum:
Expand Down

0 comments on commit d3ea54b

Please sign in to comment.