#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>
//put additional include files here
#include <GetNbox.h> ///---Sim 11-20-2006 SUPPORT_DND_OPEN_DIALOG
#include <..\originlab\theme_utils.h> ///---Sim 10-27-2008 QA80-12422 SUPPORT_SAVE_SHEET_THEME_FOR_ALL_SHEET_IMPORT_FILE
#include <..\originlab\fu_utils.h>// Hong 9/14/06 REMOVE_IMPORT_RELATED_TO_FU_UTILS
#include <..\originlab\earthprobedata.c>

//put your own support static functions here
///////////////////////////////////////////////////////////////////////
//////// modification log
/// Hong 03/28/07 v8.0591 CENTRALIZE_CHECK_CALID_RANGE
/// Hong 04/10/07 v8.0597b IGNORE_FNAME$_WHEN_FROM_MENU
/// Sim 04-30-2007 TEMP_FIX_IMPORT_MODE_FOR_SINGLE_FILE
/// Sim 06-25-2007 UPDATE_ORGANIZER
/// Hong 09/26/07 8.0709 CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
/// Hong 10/24/07 QA80-10541 FIX_FILEPATH_CONTAIL_ALL_FILES_PATH
/// Hong 07/21/08 v8.0905 REMOVE_REPLACE_MODE_FROM_MULTI_IMPORT_MODE
/// Sim 10-27-2008 QA80-12422 SUPPORT_SAVE_SHEET_THEME_FOR_ALL_SHEET_IMPORT_FILE
/// Hong 01/13/09 v8.0995d FIX_D&D_MATRIX_ONLY_FILE_RUNTIME_IF_FILTER_USE_WKS_AS_TARGET_PAGE
///////////////////////////////////////////////////////////////////////

enum {
	ERR_FAIL_IMPORT  = XF_LOCAL_ERR_BEGIN,
};
/// Hong 01/18/07 ADD_IMPORT_MODE
enum {
	IML_REPLACE = 0, // ASCIMP_MODE_REPLACE_DATA,
	IML_NEW_BK, // ASCIMP_MODE_NEW_BOOKS,
	IML_NEW_SHT, // ASCIMP_MODE_NEW_SHEETS,
};
#define IML_NUM_MODES 3
/// end ADD_IMPORT_MODE
///---Sim 11-16-2006 RELIABLE_OK_ENABLE
static bool s_bFileValid = true;
#define OK_SURE(_OK_ENABLE) _OK_ENABLE = s_bFileValid; //also can be _OK_ENABLE = s_bFileValid && s_bSetting
///---END RELIABLE_OK_ENABLE

///---Sim 11-07-2006 HANDLE_ERR_MESSAGE_USE_DLL
// change the internal error message of MiniTab import function to external error code of DLL
static void _shift_error_code(int& nRet)
{
	switch ( nRet )
	{
	case EPR_ERR_FILE_OPEN:
		nRet = IMPERR_FAILED_OPEN;
		break;
	case EPR_ERR_HEADER:
		nRet = IMPERR_HEADER;
		break;
	case EPR_ERR_READ_DATA:
		nRet = IMPERR_FAILED_READ;
		break;
	case EPR_ERR_NO_FILE_SPECIFIED:
		nRet = CER_EMPTY_FILENAME;
		break;
	case EPR_ERR_TARGET_MATRIX_NOT_VALID:
		nRet = CER_INVALID_MATRIX;
		break;
	case EPR_ERR_UNKNOWN_FILE_EXT:
		nRet = IMPERR_UNKNOW_TYPE;
		break;
	case EPR_ERR_PARSE_DATA:
		nRet = IMPERR_EP_PARSE_DATA;
		break;
	default:
		nRet = CER_UNKNOWN_ERROR;
	}
}
///---END HANDLE_ERR_MESSAGE_USE_DLL

///---Sim 01-18-2007 SHOW_FILE_INFO
static BOOL _construct_tree_setting(StringArray& vsFileNames, TreeNode& trInfo)
{
	int nCount = vsFileNames.GetSize();
	string strFileName, strTag, strInfo;
	if ( trInfo )
		trInfo.RemoveChildrenWithPrefix();
	
	GETN_USE(trInfo)
	for ( int nIndex = 0; nIndex < nCount; nIndex++ )
	{
		strFileName = vsFileNames[nIndex];
		if ( !strFileName.IsFile() )
			return false;

		strTag.Format("file%d", nIndex+1);
		strInfo.Format("File Size: %s ", GetFileSize(strFileName));
		GETN_STR(strTag, GetFileName(strFileName, false), strInfo )
		GETN_READ_ONLY
	}
	return true;
}
///---END SHOW_FILE_INFO

///---Sim 11-20-2006 SUPPORT_DND_OPEN_DIALOG
static bool file_name_event(TreeNode& trGetN, string& strErrMsg)
{
	string strFileName = trGetN.fname.strVal;

	// clean the trFiles on GUI
	//trGetN.trSetting.RemoveChildrenWithPrefix();
	TreeNode trNode = trGetN.trFiles;
	trNode.RemoveChildrenWithPrefix();
	
	if ( !check_imported_file_name(strFileName, strErrMsg) )
		return false;
	
	StringArray vsFileNames;
	separate_multiline_files(strFileName, vsFileNames);
	if ( !_construct_tree_setting(vsFileNames, trNode) )
	{
		// clean the trFiles on GUI
		trNode.RemoveChildrenWithPrefix();
		strErrMsg = CER_INVALID_IMPORT_DATA_FILE;
		return false;
	}
	return true;
}
///---END SUPPORT_DND_OPEN_DIALOG


void impEP(const string& fname, const TreeNode& trFiles, const TreeNode& options, Range& orng, TreeNode& finfo)
{
	/// Hong 9/28/06 ADD_ERROR_MESSAGE_IF_FILE_INVALID
	if( fname == NULL )
		XF_THROW(CER_INVALID_IMPORT_DATA_FILE);
	/// END ADD_ERROR_MESSAGE_IF_FILE_INVALID	
	/// Hong 01/18/07 ADD_IMPORT_MODE
	// XF impmode list is "Replace Data, new books, new sheets", value is 0,1,2
	/// Hong 06/07/05 v8.0635 ADD_OPTION_TREE_FOR_MAKE_FILTER
	/*
	int nListIndexToImportMode[] = {
		ASCIMP_MODE_REPLACE_DATA,
		ASCIMP_MODE_NEW_BOOKS,
		ASCIMP_MODE_NEW_SHEETS
	};
	int nFileImportMode = ASCIMP_MODE_NEW_BOOKS;
	if( 0 <= impmode && impmode < IML_NUM_MODES )
		nFileImportMode = nListIndexToImportMode[impmode];
	*/
	/// end ADD_OPTION_TREE_FOR_MAKE_FILTER
	/// end ADD_IMPORT_MODE
	/// Hong 01/18/07 GET_TARGET_LAYER_BY_RANGE
	// Get target matrix by name.
	//MatrixLayer matlayer;
	//Layer layer = Project.ActiveLayer();
	//if( EXIST_MATRIX != layer.GetPage().GetType() )
		//matlayer.Create();
	//else
		//matlayer = (MatrixLayer)layer;
	Datasheet ds;
	int c1, c2;
	/// Hong 03/28/07 v8.0591 CENTRALIZE_CHECK_CALID_RANGE
	//orng.GetRange(ds, c1, c2);
	Page pg;
	if ( !GetRangeInfo(orng, ds, pg, c1, c2) )
		XF_THROW(XFERR_INVALID_RANGE);
	/// end CENTRALIZE_CHECK_CALID_RANGE
	MatrixLayer matlayer(ds);
	if( !matlayer )
	/// AW 02/28/07 8/0272c ADD_NEW_MATRIX_PAGE_WHEN_ACTIVE_WINDOW_IS_WKS
	//	XF_THROW(CER_INVALID_MATRIX);
	{
		MatrixPage MatPg;
		MatPg.Create("Origin");
		matlayer = MatPg.Layers(0);
		
		///---Sim 03-07-2007 FIX_IMPORT_RANGE_ERROR
		//if ( orng.IsValid() )
		//{
			//orng.Reset();
			//orng.Add(matlayer, 0);
		//}
		///---END 03-07-2007 FIX_IMPORT_RANGE_ERROR
	}
	/// END ADD_NEW_MATRIX_PAGE_WHEN_ACTIVE_WINDOW_IS_WKS
	
	///---Sim 03-09-2007 TEMP_FIX_HIGHLINE_REPLACE_DATA
	/// Hong 09/08/07 v8.0698b FIX_FAIL_DUMP_OUTPUT_RANGE_ORNG
	/*
	if ( orng )
	{
		orng.Reset();
		orng.Add(matlayer, 0);
	}
	*/
	reset_range_to_first_obj(orng, matlayer);
	/// end FIX_FAIL_DUMP_OUTPUT_RANGE_ORNG
	///---END TEMP_FIX_HIGHLINE_REPLACE_DATA
	
	
	//Page pg; /// Hong 03/28/07 v8.0591 CENTRALIZE_CHECK_CALID_RANGE
	matlayer.GetParent(pg);
	///---Sim 09-12-2006 SUPPPORT_DEFAULT_FILTER_IS_EMPTY
	TreeNode tnUsingFilter;
	int nVer;
	/// Hong 06/07/05 v8.0635 ADD_OPTION_TREE_FOR_MAKE_FILTER
	//if ( fuGetDouble(trFilter, IDE_DISP_IMP_ORIGINVER, nVer) )
	//	tnUsingFilter = trFilter;
	if ( fuGetDouble(options, IDE_DISP_IMP_ORIGINVER, nVer) )
		tnUsingFilter = options;
	
	int nFileImportMode = fuGetImportMode(tnUsingFilter);
	/// end ADD_OPTION_TREE_FOR_MAKE_FILTER
	///---END SUPPPORT_DEFAULT_FILTER_IS_EMPTY
	/// Hong 01/13/09 v8.0995d FIX_D&D_MATRIX_ONLY_FILE_RUNTIME_IF_FILTER_USE_WKS_AS_TARGET_PAGE
	// design refer to /// AW 02/28/07 8/0272c ADD_NEW_MATRIX_PAGE_WHEN_ACTIVE_WINDOW_IS_WKS
	if ( EXIST_WKS == fuGetTargetPage(tnUsingFilter) )
		fuSetTargetPage(tnUsingFilter, EXIST_MATRIX);
	/// end FIX_D&D_MATRIX_ONLY_FILE_RUNTIME_IF_FILTER_USE_WKS_AS_TARGET_PAGE
	
	int nRet, nCols;
	StringArray vsFileNames;
	separate_multiline_files(fname, vsFileNames); 
	
	int nFileCount = vsFileNames.GetSize();
	if ( nFileCount <= 0 )
		XF_THROW(CER_INVALID_IMPORT_DATA_FILE);
	
	int nIndexLayer = pg.Layers.Count();
	Layer lyOlder;
	bool bNewLayer, bEmptyLayer;
	set_active_layer(ds);
	
	waitCursor wc; 
	for ( int ii = 0; ii < nFileCount; ii++ )
	{
		//matlayer = GetTargetLayer(pg, nIndexLayer, 0, tnUsingFilter, true, orng, nFileImportMode);
		//Matrix mEP(matlayer);
		//
		lyOlder = pg.Layers();
		/// Hong 06/07/07 v8.0635 ADD_OPTION_TREE_FOR_MAKE_FILTER
		/* remove temp code
		///---Sim 04-30-2007 TEMP_FIX_IMPORT_MODE_FOR_SINGLE_FILE
		if ( 0 == ii )
		{
			int nImportMode = get_first_file_import_mode(FILE_TYPE_EP);
			TreeNode trInValid;
			
			matlayer = GetTargetLayer(pg, nIndexLayer, ii, trInValid, true, orng, nImportMode);
		}
		else
		{
			matlayer = GetTargetLayer(pg, nIndexLayer, ii, tnUsingFilter, true, orng, nFileImportMode);
		}
		///---END TEMP_FIX_IMPORT_MODE_FOR_SINGLE_FILE
		*/
		matlayer = GetTargetLayer(pg, nIndexLayer, ii, tnUsingFilter, true, orng, nFileImportMode);
		/// end ADD_OPTION_TREE_FOR_MAKE_FILTER		
		bNewLayer = !is_same_layer(lyOlder, matlayer); 
	
		/// end GET_TARGET_LAYER_BY_RANGE
		// Import specified EPA file into specified matrix.
		Matrix mEP(matlayer);
		nRet = EarthProbe_FileToMatrix(mEP, vsFileNames[ii]);
		
		/// Hong 06/07/05 v8.0635 ADD_OPTION_TREE_FOR_MAKE_FILTER
		DataRange drImported;
		drImported.Add(matlayer, 0, STR_RANGE_STR);
		
		setPageAndLayerName(drImported, vsFileNames[ii], tnUsingFilter, 0);
		impinfo_UpdateExistingData(pg, drImported);
		
		Tree trDataRange;
		getRangeInfo(trDataRange, drImported);
		/// end ADD_OPTION_TREE_FOR_MAKE_FILTER
		
		if(nRet < 0)
		{
			///---Sim 11-07-2006 HANDLE_ERR_MESSAGE_USE_DLL
			//XF_THROW(ERR_FAIL_IMPORT);
			_shift_error_code(nRet);
			//XF_THROW_EX(nRet, GetFileName(fname));
			XF_THROW_EX(nRet, GetFileName(vsFileNames[ii])); /// Hong 10/24/07 QA80-10541 FIX_FILEPATH_CONTAIL_ALL_FILES_PATH
			///---END HANDLE_ERR_MESSAGE_USE_DLL
		}
		
		bEmptyLayer = (1 == is_sheet_empty(matlayer)) ? true : false;
		if ( bNewLayer && bEmptyLayer )
		{
			matlayer.Destroy();
		}
		set_active_layer(pg.Layers()); 
		
		/// Hong 06/07/05 v8.0635 ADD_OPTION_TREE_FOR_MAKE_FILTER
		//impinfo_AddFile(matlayer, fname, finfo, ASCIMP_MODE_NEW_SHEETS, FILTER_TYPE_XFUNC, trFilter);
		/// Hong 10/24/07 QA80-10541 FIX_FILEPATH_CONTAIL_ALL_FILES_PATH
		//impinfo_AddFile(matlayer, fname, finfo, ASCIMP_MODE_NEW_SHEETS, FILTER_TYPE_XFUNC, tnUsingFilter, ii + 1, trDataRange);
		impinfo_AddFile(matlayer, vsFileNames[ii], finfo, ASCIMP_MODE_NEW_SHEETS, FILTER_TYPE_XFUNC, tnUsingFilter, ii + 1, trDataRange);
		/// end FIX_FILEPATH_CONTAIL_ALL_FILES_PATH
		/// end ADD_OPTION_TREE_FOR_MAKE_FILTER
	}
	//refresh_organizer_gui(pg); ///---Sim 06-25-2007 UPDATE_ORGANIZER
	
}

//nEventID < 0 on event, like GETNE_ON_INIT, GETNE_ON_OK etc, >0 on change from control
//return 0 to do nothing, return PEVENT_GETN_RET_TO_CLOSE to close dialog
//dwEnables = bOKEnable, bBTN1Enable, bBTN2Enable, bBTN3Enable, , can set to false to disable OK/Apply buttons
//lpcszNodeName = the trGetN TreeNode tag name that generates the event, or is  if GETNE_ON_OK etc
//strAux = optional string for XF Wizard Bar, like DLG_NEED_CHANGE_GRID etc, it will be invalid if from internal node value change event
//strErrMsg = allowing messages to be shown
int impEP_event1(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	if( xf_is_extended_event(nEventID) )
		return impEP_event1_ex(trGetN, nRow, nEventID, dwEnables, lpcszNodeName, DynaCntrlContainer, strAux, strErrMsg);
	DECLARE_BUTTON_ENABLES
	
	OK_SURE(bOKEnable); ///---Sim 11-16-2006 RELIABLE_OK_ENABLE
	
	///---Sim 11-20-2006 SUPPORT_DND_OPEN_DIALOG
	if ( GETNE_ON_INIT == nEventID || GETNE_ON_THEME == nEventID )
	{
		s_bFileValid = file_name_event(trGetN, strErrMsg);
		OK_SURE(bOKEnable);
		return true;
	}
	///---END SUPPORT_DND_OPEN_DIALOG
	
	///---Sim 11-1-2006 CHECK_FILE_NAME
	string strTagName = lpcszNodeName;
	if(strTagName == "fname") // file name changed, either on start of later user changed
	{
		///---Sim 11-20-2006 SUPPORT_DND_OPEN_DIALOG
		s_bFileValid = file_name_event(trGetN, strErrMsg);
		OK_SURE(bOKEnable);
		return true;
		/*
		s_bFileValid = true; ///---Sim 11-16-2006 RELIABLE_OK_ENABLE
		OK_SURE(bOKEnable); ///---Sim 11-16-2006 RELIABLE_OK_ENABLE
	
		///---Sim 10-30-2006 ERROR_MESSAGE
		int nErrCode = CER_NO_ERROR;
		int nInvalidFileIdx = 0;
	
		if ( trGetN.fname.strVal.IsEmpty() )
		{
			nErrCode = CER_EMPTY_FILENAME;
		}
		else if ( !is_valid_filename(trGetN.fname.strVal, nInvalidFileIdx) )
		{
			nErrCode = CER_INVALID_FILENAME_INDEX;
		}
				
		if(CER_NO_ERROR != nErrCode)
		{
			strErrMsg = nErrCode;
			
			if ( CER_INVALID_FILENAME_INDEX == nErrCode )
			{
				strErrMsg += ":";
				strErrMsg += nInvalidFileIdx;
			}
			
			//DynaCntrlContainer.PostMessage(WM_USER_MSG_ON_DLG, nErrCode, nInvalidFileIdx);    
			s_bFileValid = false; ///---Sim 11-16-2006 RELIABLE_OK_ENABLE
			OK_SURE(bOKEnable); ///---Sim 11-16-2006 RELIABLE_OK_ENABLE
			
			//return true;
		}
		///---END ERROR_MESSAGE
		
		return true;
		*/
		///---END SUPPORT_DND_OPEN_DIALOG
	}
	///---END CHECK_FILE_NAME
	return false;

}

int impEP_make_tree(TreeNode& tr, LPCSTR lpcszVarName)
{
	/// Hong 06/07/05 v8.0635 ADD_OPTION_TREE_FOR_MAKE_FILTER
	if ( 0 == strcmp(lpcszVarName, "options") )
	{
		constructOptionsForXF(tr, true, true, false, false, false, false);
		
		// custom import mode list
		///---Sim 05-08-2007 ADD_OPTIONS_FOR_IMPORT_MODE_OF_1ST_FILE
		TreeNode tr1stImportMode = tree_get_node_by_id(tr, IDE_DISPIMP_1STMODE, true);
		if ( tr1stImportMode )
		{
			string strCombo, strMapping;
			strCombo = getImportModeListString(strMapping, LIST_IMPORT_MODE_REPLACE_BOOK_SHEET);
			tr1stImportMode.SetAttribute(STR_COMBO_ATTRIB, strCombo);
			tr1stImportMode.SetAttribute(STR_INTMAP_ATTRIB, strMapping);
			tr1stImportMode.nVal = ASCIMP_MODE_REPLACE_DATA;
		}
		///---END ADD_OPTIONS_FOR_IMPORT_MODE_OF_1ST_FILE
		TreeNode trImportMode = tree_get_node_by_id(tr, IDE_IMP_IMPORTMODE, true);
		if ( trImportMode )
		{
			string strCombo, strMapping;
			/// Hong 07/21/08 v8.0905 REMOVE_REPLACE_MODE_FROM_MULTI_IMPORT_MODE
			//strCombo = getImportModeListString(strMapping, LIST_IMPORT_MODE_REPLACE_BOOK_SHEET);
			strCombo = getImportModeListString(strMapping, LIST_IMPORT_MODE_BOOK_SHEET);
			/// end REMOVE_REPLACE_MODE_FROM_MULTI_IMPORT_MODE
			trImportMode.SetAttribute(STR_COMBO_ATTRIB, strCombo);
			trImportMode.SetAttribute(STR_INTMAP_ATTRIB, strMapping);
			trImportMode.nVal = ASCIMP_MODE_NEW_BOOKS;
		}
				
		fuSetXFunctionName(tr, "impep");
		fuSetTargetPage(tr, EXIST_MATRIX);
		return 0;
	}
	///---END ADD_OPTION_TREE_FOR_MAKE_FILTER
	
	return false;
}
//nGetNDialog = 0,1,2, corresponding to the XF GetN dropdown, 0 = dialog is not used
//you can change nRet to be one of XFEVT_PROCEED (defualt), XFEVT_ABORT, XFEVT_PROCEED_NO_DLG or XFEVT_PROCEED_WITH_DLG(when nGetNDialog = 0)
//nGetNDialog = -1 when Ok on GetN dialog to allow handler to preocess <auto> etc variables
//dwCntrl is combination of bits
//LTXF_FROM_GUI_MENU, LTXF_FROM_GUI_PROMPT, LTXF_FROM_AUTO_UPDATE, LTXF_FROM_FUNCTION, LTXF_THEME_USED, LTXF_CHANGE_PARAM
void impEP_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{
	
	if(nGetNDialog > 0)
	{
		trGetN.finfo.Show = 0;
		trGetN.trFilter.Show = 0;
	}
	/// Hong 01/18/07 ADD_IMPORT_MODE
	if(nGetNDialog >= 0)
	//--------------
	{
		/// Hong 06/07/05 v8.0635 ADD_OPTION_TREE_FOR_MAKE_FILTER
		/*
		TreeNode trFilter = trGetN.trFilter;
		if ( trFilter.IsValid() && trFilter.GetNodeCount()>0 )
		{
			///---Sim 09-27-2006 TRANSLATE_FILTER_IMPORT_MODE_TO_XF_PARAM
			//trGetN.FileImpotMode.nVal = fuGetImportMode(trFilter);
	
			// XF impmode list is "Replace Data, new books, new sheets"
			int iMode = IML_NEW_BK; // default new book
			switch ( fuGetImportMode(trFilter) )
			{
			case ASCIMP_MODE_REPLACE_DATA:
				iMode = IML_REPLACE;
				break;
			case ASCIMP_MODE_NEW_BOOKS:
				iMode = IML_NEW_BK;
				break;
			case ASCIMP_MODE_NEW_SHEETS:
				iMode = IML_NEW_SHT;
				break;
			}
			trGetN.impmode.nVal = iMode; 
			///---END TRANSLATE_FILTER_IMPORT_MODE_TO_XF_PARAM
		}
		*/
		/// end ADD_OPTION_TREE_FOR_MAKE_FILTER
	}
	/// end ADD_IMPORT_MODE
	/// Hong 12/22/06 CHECK_FNAME_EMPTY_UNASSIGNED
	if(nGetNDialog > -1)
	{
		string strFileName = trGetN.fname.strVal;
		
		/// Hong 04/10/07 v8.0597b IGNORE_FNAME$_WHEN_FROM_MENU
		if ( LTXF_FROM_GUI_MENU & dwCntrl ) // if from menu, ignore default value fname$
			strFileName = "";
		/// end IGNORE_FNAME$_WHEN_FROM_MENU
		
		if(is_empty_or_unassigned(strFileName))
		{			
			/// Hong 05/31/07 v8.0630 MORE_ON_ACCESS_TO_FDLOG
			//int nFilesRet = get_open_box_by_file_group(strFileName, "EarthProbe", "EarthProbe", true);
			int nFilesRet;
			if ( 0 != nGetNDialog )
			{
				int nShowOptionsDlg = 1;
				/// Hong 09/26/07 8.0709 CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
				//nFilesRet = get_open_box_by_file_group(strFileName, "EarthProbe", _L("EarthProbe"),
				//	OPENBOX_FLAG_MULTIFILES, NULL, NULL, _L("Show Options Dialog"), &nShowOptionsDlg);
				///---Sim 10-27-2008 QA80-12422 SUPPORT_SAVE_SHEET_THEME_FOR_ALL_SHEET_IMPORT_FILE
				//nFilesRet = get_open_box_by_file_group(strFileName, "EarthProbe", NULL,
					//OPENBOX_FLAG_MULTIFILES, NULL, NULL, STR_SHOW_OPT_DLG, &nShowOptionsDlg);
				nFilesRet = get_open_box_by_file_group(strFileName, "EarthProbe", NULL,
					OPENBOX_FLAG_MULTIFILES, NULL, NULL, get_show_options_label(trGetN), &nShowOptionsDlg);
				///---END QA80-12422 SUPPORT_SAVE_SHEET_THEME_FOR_ALL_SHEET_IMPORT_FILE
				/// end CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
				nRet = (nShowOptionsDlg ? XFEVT_PROCEED : XFEVT_PROCEED_NO_DLG);
			}
			else
			{
				//nFilesRet = get_open_box_by_file_group(strFileName, "EarthProbe", _L("EarthProbe"), true);
				nFilesRet = get_open_box_by_file_group(strFileName, "EarthProbe", NULL, true); /// Hong 09/26/07 8.0709 CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
			}
			/// end MORE_ON_ACCESS_TO_FDLOG
			/// end THEME_FILENAME_WORKBOOK_AND_WORKSHEET
			if ( 0 == nFilesRet )
			{
				nRet = XFEVT_ABORT;
				//warning_msg_box(XFERR_UI_USER_CANCEL, false);
				return;
			}
			///---END HANDLE_USER_CANCEL_OPEN_FILE_BOX
			trGetN.fname.strVal = strFileName;
			string strErrMsg;
			if( !file_name_event(trGetN, strErrMsg) )
			{
				/// Hong 03/21/07 v8.0586 FIX_FAIL_DUMP_CORRECT_ERROR_STRING
				//nRet = XFEVT_ABORT;
				//warning_msg_box(strErrMsg, false);
				int nErrMsg = atoi(strErrMsg);
				nRet = XFEVT_ABORT;
				warning_msg_box(nErrMsg, false, 'E'); // should pass an int ///---Sim 06-19-2007 IMPROVE_WARNING_MESSAGE_POST_FUNCTION
				/// end FIX_FAIL_DUMP_CORRECT_ERROR_STRING
				return;
			}
		}
	}
	/// end CHECK_FNAME_EMPTY_UNASSIGNED
}
//nEventID < 0 on event, like GETNE_ON_INIT, GETNE_ON_OK etc, >0 on change from control
//return 0 to do nothing, return PEVENT_GETN_RET_TO_CLOSE to close dialog
//dwEnables = bOKEnable, bBTN1Enable, bBTN2Enable, bBTN3Enable, , can set to false to disable OK/Apply buttons
//lpcszNodeName = the trGetN TreeNode tag name that generates the event, or is  if GETNE_ON_OK etc
//strAux = optional string for XF Wizard Bar, like DLG_NEED_CHANGE_GRID etc, it will be invalid if from internal node value change event
//strErrMsg = allowing messages to be shown
int impEP_event1_ex(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	return false;
}
