#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>
enum{
	content_full,
	content_partial,
};


//put additional include files here
//put your own support static functions here
/// Hong 23/05/08 QA80-11565 DOC2XF_ALLOW_SKIP_CONTENTS_LIKE_PARAMETERS
//typedef bool (* FUNC_UPDATE_XFS) (const string& strXFName, const int& nlanguage, const string& strFolder);
typedef bool (* FUNC_UPDATE_XFS) (const string& strXFName, const int& nlanguage, const string& strFolder, bool bParitalContent);
/// end DOC2XF_ALLOW_SKIP_CONTENTS_LIKE_PARAMETERS


void doc2xf(const string& xfname, const int& language, const string& path, const int& allxf, const int& content)
{
	/// Hong 23/05/08 QA80-11565 DOC2XF_ALLOW_SKIP_CONTENTS_LIKE_PARAMETERS
	/*
	//code begin
	FUNC_UPDATE_XFS fnOne = Project.FindFunction("update_xf", "originlab\\xfdocument.c", true, true, true);
	FUNC_UPDATE_XFS fnAll = Project.FindFunction("update_xfs", "originlab\\xfdocument.c", true, true, true);
	
	bool	bPartialContent = (content_full == content) ? false : true; /// Hong 23/05/08 QA80-11565 DOC2XF_ALLOW_SKIP_CONTENTS_LIKE_PARAMETERS
	string strFile;
	///Cheney 2007-6-18 UPDATE_XF_ERR_THROW
	//string strErrPrompts("Fail during call update function");
	///end UPDATE_XF_ERR_THROW
	//if(xfname.IsEmpty() || "<>"==xfname || "<optional>"==xfname)
	if(1 == allxf)
	{
		//update from all folder file		
		if(!fnAll || !fnAll(path, language, path))				
			///Cheney 2007-6-18 UPDATE_XF_ERR_THROW
			//out_str(strErrPrompts);
			warning_msg_box(XFERR_FAIL_DURING_CALL_CREATE_FUNC, false, 'E');
			///end UPDATE_XF_ERR_THROW
	}
	else
	{
		//update by single file		
		if(!fnOne || !fnOne(xfname, language, path))		
			///Cheney 2007-6-18 UPDATE_XF_ERR_THROW
			//out_str(strErrPrompts);
			warning_msg_box(XFERR_FAIL_DURING_CALL_CREATE_FUNC, false, 'E');
			///end UPDATE_XF_ERR_THROW
	}
	///end
	*/
	bool		bParitalContent = (content_full == content) ? false : true;
	string		strFunctionName, strFilePath("originlab\\xfdocument.c");
	strFunctionName = (1 == allxf) ? "update_xfs" : "update_xf";
	
	FUNC_UPDATE_XFS	fn = Project.FindFunction(strFunctionName, strFilePath, true, true, true);
	if ( !fn || !fn(xfname, language, path, bParitalContent) )
		warning_msg_box(XFERR_FAIL_DURING_CALL_CREATE_FUNC, false, 'E');
	/// end DOC2XF_ALLOW_SKIP_CONTENTS_LIKE_PARAMETERS	
}

//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 doc2xf_event1(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	if( xf_is_extended_event(nEventID) )
		return doc2xf_event1_ex(trGetN, nRow, nEventID, dwEnables, lpcszNodeName, DynaCntrlContainer, strAux, strErrMsg);
	DECLARE_BUTTON_ENABLES
	return false;

}

int doc2xf_make_tree(TreeNode& tr, LPCSTR lpcszVarName)
{
	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 doc2xf_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{

}
//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 doc2xf_event1_ex(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	return false;
}
