#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>
#include <tree_utils.h>
//put additional include files here

//put your own support static functions here

/// Hong 11/28/06 MAKE_JULIAN_DATE_MORE_READABLE
static void _show_julian_date_by_string_mode(TreeNode& trNode)
{
	if(!trNode.IsValid())
		return ;
	double dJulian = trNode.dVal;
	string strVal = get_date_str(dJulian);
	trNode.strVal = strVal;
}
/// end MAKE_JULIAN_DATE_MORE_READABLE


void impinfo(const Page& ipg, const int& findex, TreeNode& trInfo, int& fcount)
{
	Tree tr;
	if( tree_get_binary_storage(tr, ipg, IFI_BINARY_STORAGE_NAME) )
	{
		/// Hong 08/07/07 QA80-10168 v8.0676 OUTPUT_IMP_FILE_COUNT
		fcount = tr.GetNodeCount();
		/// end OUTPUT_IMP_FILE_COUNT
		
		/// Hong 08/07/07 QA80-10168 v8.0676 FINDEX_USE_LT_OFFSET
		//if ( -1 == findex )
		if ( 0 == findex )
		/// end FINDEX_USE_LT_OFFSET
			trInfo = tr.LastNode;
		else
		{
			/// Hong 08/07/07 v8.0676 FINDEX_USE_LT_OFFSET
			//if ( findex >=0 && findex < tr.GetNodeCount() )			
			//	trInfo = tr.Children.Item(findex);
			if ( findex >= 1 && findex < fcount + 1)			
				trInfo = tr.Children.Item(findex - 1);
			/// end FINDEX_USE_LT_OFFSET
			else
			{
				XF_THROW(XFERR_INVALID_ARG);
			}
		}
		/// Hong 08/07/07 QA80-10168 v8.0676 REMOVE_BRANCH_VARIABLE
		/*
		if ( !branch.IsEmpty() )
		{
			TreeNode trNode = tree_get_node_by_tagname(trInfo, branch, true );
			if ( trNode )
			{
				trInfo = trNode;
				return;
			}
			string str;
			str.Format("variable %s not found.\n", branch);
			out_str(str);		
		}
		*/
		/// end REMOVE_BRANCH_VARIABLE
		/// Hong 11/28/06 MAKE_JULIAN_DATE_MORE_READABLE
		_show_julian_date_by_string_mode(trInfo.Info.ImportDate);
		_show_julian_date_by_string_mode(trInfo.Info.FileDate);
		/// end MAKE_JULIAN_DATE_MORE_READABLE		
	}
	else
		out_str(_L("ImportFileInfo not found.\n"));	
}

//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 impinfo_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{

}
