Skip to content
Open
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
12 changes: 12 additions & 0 deletions Src/xWorks/DictionaryExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ public void ExportWordDictionary(string filePath, int[] entriesToSave, RecordCle
filePath, progress);
}

public void ExportWordClassifiedDictionary(string filePath, int[] entriesToSave, RecordClerk clerk,
DictionaryPublicationDecorator pubDecorator, IThreadedProgress progress)
{
if (progress != null)
progress.Maximum = entriesToSave.Length;

var dictConfig = new DictionaryConfigurationModel(
DictionaryConfigurationListener.GetCurrentConfiguration(m_propertyTable, "Classified Dictionary"), m_cache);
LcmWordGenerator.SavePublishedDocx(entriesToSave, clerk, pubDecorator, int.MaxValue, dictConfig, m_propertyTable,
filePath, progress);
}

public void ExportWordReversal(string filePath, string reversalWs, int[] entriesToSave, RecordClerk revClerk,
DictionaryPublicationDecorator pubDecorator, DictionaryConfigurationModel revConfig, IThreadedProgress progress)
{
Expand Down
95 changes: 56 additions & 39 deletions Src/xWorks/ExportDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ protected internal enum FxtTypes
kftSemanticDomains,
kftWebonary,
kftWordOpenXml,
kftWordClassifiedDict,
kftPhonology
}
// ReSharper restore InconsistentNaming
Expand All @@ -100,7 +101,7 @@ protected internal struct FxtType
public string m_sXsltFiles;
public string m_path; // Used to keep track of items after they are sorted.
}
protected List<FxtType> m_rgFxtTypes = new List<FxtType>(8);
protected List<FxtType> m_rgFxtTypes = new List<FxtType>(9);

protected ConfiguredExport m_ce = null;
protected XmlSeqView m_seqView = null;
Expand Down Expand Up @@ -368,10 +369,8 @@ private void InitializeComponent()
this.columnHeader2});
this.m_exportList.FullRowSelect = true;
this.m_exportList.HideSelection = false;
this.m_exportList.MinimumSize = new Size(256, 183);
this.m_exportList.MultiSelect = false;
this.m_exportList.Name = "m_exportList";
this.m_exportList.ListViewItemSorter = new ExportListComparer();
this.m_exportList.Sorting = SortOrder.Ascending;
this.m_exportList.UseCompatibleStateImageBehavior = false;
this.m_exportList.View = View.Details;
Expand Down Expand Up @@ -644,6 +643,7 @@ private void btnExport_Click(object sender, EventArgs e)
ProcessWebonaryExport();
return;
case FxtTypes.kftWordOpenXml:
case FxtTypes.kftWordClassifiedDict:
default:
using (var dlg = new SaveFileDialogAdapter())
{
Expand Down Expand Up @@ -844,6 +844,7 @@ protected void DoExport(string outPath, bool fLiftOutput)
progressDlg.RunTask(true, ExportPhonology, outPath, ft.m_sDataType, ft.m_sXsltFiles);
break;
case FxtTypes.kftWordOpenXml:
case FxtTypes.kftWordClassifiedDict:
progressDlg.Minimum = 0;
progressDlg.Maximum = 1000;
progressDlg.AllowCancel = true;
Expand Down Expand Up @@ -965,55 +966,68 @@ private void GetClassifiedDictionaryDomains(DictionaryExportService exportServic

private object ExportWordOpenXml(IThreadedProgress progress, object[] args)
{

var exportType = m_rgFxtTypes[FxtIndex((string)m_exportItems[0].Tag)].m_ft;

if (args.Length < 1)
return null;
var filePath = (string)args[0];
var exportService = new DictionaryExportService(m_propertyTable, m_mediator);

// Export the main dictionary.
GetDictionaryEntries(exportService, out var clerk, out var pubDecorator, out var entriesToSave);
exportService.ExportWordDictionary(filePath, entriesToSave, clerk, pubDecorator, progress);

// Export all the reversals.
var revClerk = exportService.GetReversalClerk();
try
switch (exportType)
{
exportService.StoreReversalData(revClerk, false);
foreach (var reversal in m_cache.ServiceLocator.GetInstance<IReversalIndexRepository>().AllInstances())
{
var revConfig = DictionaryConfigurationModel.GetReversalConfigurationModel(reversal.WritingSystem, m_cache, m_propertyTable);
if (revConfig != null)
case FxtTypes.kftWordClassifiedDict:
// Export the classified dictionary
GetClassifiedDictionaryDomains(exportService, out var classifiedClerk, out var classifiedDecorator, out var domainsToSave);
exportService.ExportWordClassifiedDictionary(filePath, domainsToSave, classifiedClerk, classifiedDecorator, progress);
break;

case FxtTypes.kftWordOpenXml:
// Export the main dictionary.
GetDictionaryEntries(exportService, out var clerk, out var pubDecorator, out var entriesToSave);
exportService.ExportWordDictionary(filePath, entriesToSave, clerk, pubDecorator, progress);

// Export all the reversals.
var revClerk = exportService.GetReversalClerk();
try
{
GetReversalEntries(reversal.Guid, exportService, revConfig, revClerk, out pubDecorator, out entriesToSave);
exportService.StoreReversalData(revClerk, false);
foreach (var reversal in m_cache.ServiceLocator.GetInstance<IReversalIndexRepository>().AllInstances())
{
var revConfig = DictionaryConfigurationModel.GetReversalConfigurationModel(reversal.WritingSystem, m_cache, m_propertyTable);
if (revConfig != null)
{
GetReversalEntries(reversal.Guid, exportService, revConfig, revClerk, out pubDecorator, out entriesToSave);

if (entriesToSave.Length > 0)
{
exportService.ExportWordReversal(filePath, reversal.WritingSystem, entriesToSave,
revClerk, pubDecorator, revConfig, progress);
}

if (entriesToSave.Length > 0)
// If we just sorted for the original reversal, then keep it's sorted objects to restore later.
exportService.UpdateSortedObjects(revClerk, reversal.Guid, false);
}
}
}
finally
{
// Restore data.
if (btnExport.InvokeRequired)
{
btnExport.Invoke(() => { exportService.RestoreReversalData(revClerk, false); });
}
else
{
exportService.ExportWordReversal(filePath, reversal.WritingSystem, entriesToSave,
revClerk, pubDecorator, revConfig, progress);
exportService.RestoreReversalData(revClerk, false);
}

// If we just sorted for the original reversal, then keep it's sorted objects to restore later.
exportService.UpdateSortedObjects(revClerk, reversal.Guid, false);
// If the reversal clerk was created as part of the export, then we need to stop suppressing
// list loading, or the 'Bulk Edit Reversal Entries' view may be blank the first time viewed.
revClerk.ListLoadingSuppressed = false;
}
}
}
finally
{
// Restore data.
if (btnExport.InvokeRequired)
{
btnExport.Invoke(() => { exportService.RestoreReversalData(revClerk, false); });
}
else
{
exportService.RestoreReversalData(revClerk, false);
}

// If the reversal clerk was created as part of the export, then we need to stop suppressing
// list loading, or the 'Bulk Edit Reversal Entries' view may be blank the first time viewed.
revClerk.ListLoadingSuppressed = false;
break;
}

return null;
}

Expand Down Expand Up @@ -1442,6 +1456,9 @@ protected virtual void ConfigureItem(XmlDocument document, ListViewItem item, Xm
case "wordOpenXml":
ft.m_ft = FxtTypes.kftWordOpenXml;
break;
case "wordClassified":
ft.m_ft = FxtTypes.kftWordClassifiedDict;
break;
case "LIFT":
ft.m_ft = FxtTypes.kftLift;
break;
Expand Down
Loading
Loading