#include "stdafx.h"

#include "xtr/dialog/ExportSchema.h"

#include "resource.h"

#include "xtr/ExteorOptions.h"

namespace xtr::dialog {

#pragma warning( push )
#pragma warning( disable : 26440 26436 26454 )

BEGIN_MESSAGE_MAP(ExportSchema, CDialog) // NOLINT

END_MESSAGE_MAP()

#pragma warning( pop )

ExportSchema::ExportSchema(CWnd* pParent)
  : CDialog(IXTRD_EXPORT_SCHEMA, pParent), options{ XTROptions::RS().exportOptions } {}

ExportSchema::~ExportSchema() {
  XTROptions::RS().exportOptions = options;
}

void ExportSchema::DoDataExchange(CDataExchange* pDX) {
  CDialog::DoDataExchange(pDX);

  ::DDX_Radio  (pDX, IXTRC_FILE_DOCX, typeRadio);
  ::DDX_Check(pDX, IXTRC_CBTYPIFICATION, options.bTyping);
  ::DDX_Check(pDX, IXTRC_CBCOMMENT, options.bComment);
  ::DDX_Check(pDX, IXTRC_CBTERMIN, options.bTerm);
  ::DDX_Check(pDX, IXTRC_CBFORMEXPR, options.bRSDef);
  ::DDX_Check(pDX, IXTRC_CBINTERPRET, options.bTextDef);

  if (pDX->m_bSaveAndValidate) {
    switch (typeRadio) {
    default: exportType = FileType::docx; break;
    case 1: exportType = FileType::csv; break;
    case 2: exportType = FileType::json; break;
    }
  }
}

} // namespace xtr::dialog